@@ -488,15 +488,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
488488 } ;
489489 } ;
490490 match kind {
491- StaticKind :: Promoted ( promoted, _) => {
492- if !self . errors_reported {
493- let promoted_body_cache = self . promoted [ * promoted] ;
494- self . sanitize_promoted ( promoted_body_cache, location) ;
495-
496- let promoted_ty = promoted_body_cache. return_ty ( ) ;
497- check_err ( self , place, promoted_ty, san_ty) ;
498- }
499- }
500491 StaticKind :: Static => {
501492 let ty = self . tcx ( ) . type_of ( * def_id) ;
502493 let ty = self . cx . normalize ( ty, location) ;
@@ -510,38 +501,28 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
510501
511502 if place. projection . is_empty ( ) {
512503 if let PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) = context {
513- let is_promoted = match place. as_ref ( ) {
514- PlaceRef {
515- base : & PlaceBase :: Static ( box Static { kind : StaticKind :: Promoted ( ..) , .. } ) ,
516- projection : & [ ] ,
517- } => true ,
518- _ => false ,
504+ let tcx = self . tcx ( ) ;
505+ let trait_ref = ty:: TraitRef {
506+ def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
507+ substs : tcx. mk_substs_trait ( place_ty. ty , & [ ] ) ,
519508 } ;
520509
521- if !is_promoted {
522- let tcx = self . tcx ( ) ;
523- let trait_ref = ty:: TraitRef {
524- def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
525- substs : tcx. mk_substs_trait ( place_ty. ty , & [ ] ) ,
526- } ;
527-
528- // To have a `Copy` operand, the type `T` of the
529- // value must be `Copy`. Note that we prove that `T: Copy`,
530- // rather than using the `is_copy_modulo_regions`
531- // test. This is important because
532- // `is_copy_modulo_regions` ignores the resulting region
533- // obligations and assumes they pass. This can result in
534- // bounds from `Copy` impls being unsoundly ignored (e.g.,
535- // #29149). Note that we decide to use `Copy` before knowing
536- // whether the bounds fully apply: in effect, the rule is
537- // that if a value of some type could implement `Copy`, then
538- // it must.
539- self . cx . prove_trait_ref (
540- trait_ref,
541- location. to_locations ( ) ,
542- ConstraintCategory :: CopyBound ,
543- ) ;
544- }
510+ // To have a `Copy` operand, the type `T` of the
511+ // value must be `Copy`. Note that we prove that `T: Copy`,
512+ // rather than using the `is_copy_modulo_regions`
513+ // test. This is important because
514+ // `is_copy_modulo_regions` ignores the resulting region
515+ // obligations and assumes they pass. This can result in
516+ // bounds from `Copy` impls being unsoundly ignored (e.g.,
517+ // #29149). Note that we decide to use `Copy` before knowing
518+ // whether the bounds fully apply: in effect, the rule is
519+ // that if a value of some type could implement `Copy`, then
520+ // it must.
521+ self . cx . prove_trait_ref (
522+ trait_ref,
523+ location. to_locations ( ) ,
524+ ConstraintCategory :: CopyBound ,
525+ ) ;
545526 }
546527 }
547528
0 commit comments