fn sanitize_place(
        &mut self,
        place: &Place<'tcx>,
        location: Location,
        context: PlaceContext,
    ) -> PlaceTy<'tcx> {
        debug!("sanitize_place: {:?}", place);

        let mut place_ty = PlaceTy::from_ty(self.body().local_decls[place.local].ty);

        for elem in place.projection.iter() {
            if place_ty.variant_index.is_none() {
                if place_ty.ty.references_error() {
                    assert!(self.errors_reported);
                    return PlaceTy::from_ty(self.tcx().ty_error());
                }
            }
            place_ty = self.sanitize_projection(place_ty, elem, place, location);
        }

        if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
            let tcx = self.tcx();
            let trait_ref = ty::TraitRef {
                def_id: tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
                substs: tcx.mk_substs_trait(place_ty.ty, &[]),
            };

            // To have a `Copy` operand, the type `T` of the
            // value must be `Copy`. Note that we prove that `T: Copy`,
            // rather than using the `is_copy_modulo_regions`
            // test. This is important because
            // `is_copy_modulo_regions` ignores the resulting region
            // obligations and assumes they pass. This can result in
            // bounds from `Copy` impls being unsoundly ignored (e.g.,
            // #29149). Note that we decide to use `Copy` before knowing
            // whether the bounds fully apply: in effect, the rule is
            // that if a value of some type could implement `Copy`, then
            // it must.
            self.cx.prove_trait_ref(
                trait_ref,
                location.to_locations(),
                ConstraintCategory::CopyBound,
            );
        }

        place_ty
    }
/// Checks that the types internal to the `place` match up with
/// what would be expected.
Checks that the types internal to the `place` match up with
what would be expected.
Checks that the types internal to the ` place ` match up with what would be expected .
fn sanitize_place(
        &mut self,
        place: &Place<'tcx>,
        location: Location,
        context: PlaceContext,
    ) -> PlaceTy<'tcx> {
        debug!("sanitize_place: {:?}", place);
        let mut place_ty = PlaceTy::from_ty(self.body().local_decls[place.local].ty);
        for elem in place.projection.iter() {
            if place_ty.variant_index.is_none() {
                if place_ty.ty.references_error() {
                    assert!(self.errors_reported);
                    return PlaceTy::from_ty(self.tcx().ty_error());
                }
            }
            place_ty = self.sanitize_projection(place_ty, elem, place, location);
        }
        if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
            let tcx = self.tcx();
            let trait_ref = ty::TraitRef {
                def_id: tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
                substs: tcx.mk_substs_trait(place_ty.ty, &[]),
            };
            // To have a `Copy` operand, the type `T` of the
            // value must be `Copy`. Note that we prove that `T: Copy`,
            // rather than using the `is_copy_modulo_regions`
            // test. This is important because
            // `is_copy_modulo_regions` ignores the resulting region
            // obligations and assumes they pass. This can result in
            // bounds from `Copy` impls being unsoundly ignored (e.g.,
            // #29149). Note that we decide to use `Copy` before knowing
            // whether the bounds fully apply: in effect, the rule is
            // that if a value of some type could implement `Copy`, then
            // it must.
            self.cx.prove_trait_ref(
                trait_ref,
                location.to_locations(),
                ConstraintCategory::CopyBound,
            );
        }
        place_ty
    }
fn sanitize_place ( & mut self , place : & Place < ' tcx > , location : Location , context : PlaceContext , ) -> PlaceTy < ' tcx > { debug ! ( " " place ) ; let mut place_ty = PlaceTy :: from_ty ( self . body ( ) . local_decls [ place . local ] . ty ) ; for elem in place . projection . iter ( ) { if place_ty . variant_index . is_none ( ) { if place_ty . ty . references_error ( ) { assert ! ( self errors_reported ) ; return PlaceTy :: from_ty ( self . tcx ( ) . ty_error ( ) ) ; } } place_ty = self . sanitize_projection ( place_ty , elem , place , location ) ; } if let PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) = context { let tcx = self . tcx ( ) ; let trait_ref = ty :: TraitRef { def_id : tcx . require_lang_item ( LangItem :: Copy , Some ( self . last_span ) ) , substs : tcx . mk_substs_trait ( place_ty . ty , & [ ] ) , } ; // To have a `Copy` operand, the type `T` of the // value must be `Copy`. Note that we prove that `T: Copy`, // rather than using the `is_copy_modulo_regions` // test. This is important because // `is_copy_modulo_regions` ignores the resulting region // obligations and assumes they pass. This can result in // bounds from `Copy` impls being unsoundly ignored (e.g., // #29149). Note that we decide to use `Copy` before knowing // whether the bounds fully apply: in effect, the rule is // that if a value of some type could implement `Copy`, then // it must. self . cx . prove_trait_ref ( trait_ref , location . to_locations ( ) , ConstraintCategory :: CopyBound , ) ; } place_ty }
Checks that the types internal to the `place` match up with
what would be expected.
Checks that the types internal to the ` place ` match up with what would be expected .
&mut self
place
&Place<'tcx>
location
Location
context
PlaceContext