@@ -405,22 +405,6 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
405
405
PlaceTy :: Ty { ty : sty }
406
406
}
407
407
} ;
408
- if let PlaceContext :: Copy = context {
409
- let tcx = self . tcx ( ) ;
410
- let trait_ref = ty:: TraitRef {
411
- def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
412
- substs : tcx. mk_substs_trait ( place_ty. to_ty ( tcx) , & [ ] ) ,
413
- } ;
414
-
415
- // In order to have a Copy operand, the type T of the value must be Copy. Note that we
416
- // prove that T: Copy, rather than using the type_moves_by_default test. This is
417
- // important because type_moves_by_default ignores the resulting region obligations and
418
- // assumes they pass. This can result in bounds from Copy impls being unsoundly ignored
419
- // (e.g., #29149). Note that we decide to use Copy before knowing whether the bounds
420
- // fully apply: in effect, the rule is that if a value of some type could implement
421
- // Copy, then it must.
422
- self . cx . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
423
- }
424
408
425
409
if !place. has_no_projection ( ) {
426
410
for elem in place. elems . iter ( ) {
@@ -442,6 +426,23 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
442
426
}
443
427
} ;
444
428
429
+ if let PlaceContext :: Copy = context {
430
+ let tcx = self . tcx ( ) ;
431
+ let trait_ref = ty:: TraitRef {
432
+ def_id : tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
433
+ substs : tcx. mk_substs_trait ( place_ty. to_ty ( tcx) , & [ ] ) ,
434
+ } ;
435
+
436
+ // In order to have a Copy operand, the type T of the value must be Copy. Note that we
437
+ // prove that T: Copy, rather than using the type_moves_by_default test. This is
438
+ // important because type_moves_by_default ignores the resulting region obligations and
439
+ // assumes they pass. This can result in bounds from Copy impls being unsoundly ignored
440
+ // (e.g., #29149). Note that we decide to use Copy before knowing whether the bounds
441
+ // fully apply: in effect, the rule is that if a value of some type could implement
442
+ // Copy, then it must.
443
+ self . cx . prove_trait_ref ( trait_ref, location. interesting ( ) ) ;
444
+ }
445
+
445
446
place_ty
446
447
}
447
448
0 commit comments