@@ -509,15 +509,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
509509 } ;
510510 } ;
511511 match kind {
512- StaticKind :: Promoted ( promoted, _) => {
513- if !self . errors_reported {
514- let promoted_body_cache = self . promoted [ * promoted] ;
515- self . sanitize_promoted ( promoted_body_cache, location) ;
516-
517- let promoted_ty = promoted_body_cache. return_ty ( ) ;
518- check_err ( self , place, promoted_ty, san_ty) ;
519- }
520- }
521512 StaticKind :: Static => {
522513 let ty = self . tcx ( ) . type_of ( * def_id) ;
523514 let ty = self . cx . normalize ( ty, location) ;
@@ -531,41 +522,28 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
531522
532523 if place. projection . is_empty ( ) {
533524 if let PlaceContext :: NonMutatingUse ( NonMutatingUseContext :: Copy ) = context {
534- let is_promoted = match place. as_ref ( ) {
535- PlaceRef {
536- base : & PlaceBase :: Static ( box Static {
537- kind : StaticKind :: Promoted ( ..) ,
538- ..
539- } ) ,
540- projection : & [ ] ,
541- } => true ,
542- _ => false ,
525+ let tcx = self . tcx ( ) ;
526+ let trait_ref = ty:: TraitRef {
527+ def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
528+ substs : tcx. mk_substs_trait ( place_ty. ty , & [ ] ) ,
543529 } ;
544530
545- if !is_promoted {
546- let tcx = self . tcx ( ) ;
547- let trait_ref = ty:: TraitRef {
548- def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
549- substs : tcx. mk_substs_trait ( place_ty. ty , & [ ] ) ,
550- } ;
551-
552- // To have a `Copy` operand, the type `T` of the
553- // value must be `Copy`. Note that we prove that `T: Copy`,
554- // rather than using the `is_copy_modulo_regions`
555- // test. This is important because
556- // `is_copy_modulo_regions` ignores the resulting region
557- // obligations and assumes they pass. This can result in
558- // bounds from `Copy` impls being unsoundly ignored (e.g.,
559- // #29149). Note that we decide to use `Copy` before knowing
560- // whether the bounds fully apply: in effect, the rule is
561- // that if a value of some type could implement `Copy`, then
562- // it must.
563- self . cx . prove_trait_ref (
564- trait_ref,
565- location. to_locations ( ) ,
566- ConstraintCategory :: CopyBound ,
567- ) ;
568- }
531+ // To have a `Copy` operand, the type `T` of the
532+ // value must be `Copy`. Note that we prove that `T: Copy`,
533+ // rather than using the `is_copy_modulo_regions`
534+ // test. This is important because
535+ // `is_copy_modulo_regions` ignores the resulting region
536+ // obligations and assumes they pass. This can result in
537+ // bounds from `Copy` impls being unsoundly ignored (e.g.,
538+ // #29149). Note that we decide to use `Copy` before knowing
539+ // whether the bounds fully apply: in effect, the rule is
540+ // that if a value of some type could implement `Copy`, then
541+ // it must.
542+ self . cx . prove_trait_ref (
543+ trait_ref,
544+ location. to_locations ( ) ,
545+ ConstraintCategory :: CopyBound ,
546+ ) ;
569547 }
570548 }
571549
0 commit comments