@@ -1182,8 +1182,6 @@ fn create_cases<'tcx>(
11821182 transform : & TransformVisitor < ' tcx > ,
11831183 operation : Operation ,
11841184) -> Vec < ( usize , BasicBlock ) > {
1185- let tcx = transform. tcx ;
1186-
11871185 let source_info = SourceInfo :: outermost ( body. span ) ;
11881186
11891187 transform
@@ -1216,85 +1214,13 @@ fn create_cases<'tcx>(
12161214 if operation == Operation :: Resume {
12171215 // Move the resume argument to the destination place of the `Yield` terminator
12181216 let resume_arg = Local :: new ( 2 ) ; // 0 = return, 1 = self
1219-
1220- // handle `box yield` properly
1221- let box_place = if let [ projection @ .., ProjectionElem :: Deref ] =
1222- & * * point. resume_arg . projection
1223- {
1224- let box_place =
1225- Place :: from ( point. resume_arg . local ) . project_deeper ( projection, tcx) ;
1226-
1227- let box_ty = box_place. ty ( & body. local_decls , tcx) . ty ;
1228-
1229- if box_ty. is_box ( ) { Some ( ( box_place, box_ty) ) } else { None }
1230- } else {
1231- None
1232- } ;
1233-
1234- if let Some ( ( box_place, box_ty) ) = box_place {
1235- let unique_did = box_ty
1236- . ty_adt_def ( )
1237- . expect ( "expected Box to be an Adt" )
1238- . non_enum_variant ( )
1239- . fields [ 0 ]
1240- . did ;
1241-
1242- let Some ( nonnull_def) = tcx. type_of ( unique_did) . ty_adt_def ( ) else {
1243- span_bug ! ( tcx. def_span( unique_did) , "expected Box to contain Unique" )
1244- } ;
1245-
1246- let nonnull_did = nonnull_def. non_enum_variant ( ) . fields [ 0 ] . did ;
1247-
1248- let ( unique_ty, nonnull_ty, ptr_ty) =
1249- crate :: elaborate_box_derefs:: build_ptr_tys (
1250- tcx,
1251- box_ty. boxed_ty ( ) ,
1252- unique_did,
1253- nonnull_did,
1254- ) ;
1255-
1256- let ptr_local = body. local_decls . push ( LocalDecl :: new ( ptr_ty, body. span ) ) ;
1257-
1258- statements. push ( Statement {
1259- source_info,
1260- kind : StatementKind :: StorageLive ( ptr_local) ,
1261- } ) ;
1262-
1263- statements. push ( Statement {
1264- source_info,
1265- kind : StatementKind :: Assign ( Box :: new ( (
1266- Place :: from ( ptr_local) ,
1267- Rvalue :: Use ( Operand :: Copy ( box_place. project_deeper (
1268- & crate :: elaborate_box_derefs:: build_projection (
1269- unique_ty, nonnull_ty, ptr_ty,
1270- ) ,
1271- tcx,
1272- ) ) ) ,
1273- ) ) ) ,
1274- } ) ;
1275-
1276- statements. push ( Statement {
1277- source_info,
1278- kind : StatementKind :: Assign ( Box :: new ( (
1279- Place :: from ( ptr_local)
1280- . project_deeper ( & [ ProjectionElem :: Deref ] , tcx) ,
1281- Rvalue :: Use ( Operand :: Move ( resume_arg. into ( ) ) ) ,
1282- ) ) ) ,
1283- } ) ;
1284-
1285- statements. push ( Statement {
1286- source_info,
1287- kind : StatementKind :: StorageDead ( ptr_local) ,
1288- } ) ;
1289- } else {
1290- statements. push ( Statement {
1291- source_info,
1292- kind : StatementKind :: Assign ( Box :: new ( (
1293- point. resume_arg ,
1294- Rvalue :: Use ( Operand :: Move ( resume_arg. into ( ) ) ) ,
1295- ) ) ) ,
1296- } ) ;
1297- }
1217+ statements. push ( Statement {
1218+ source_info,
1219+ kind : StatementKind :: Assign ( Box :: new ( (
1220+ point. resume_arg ,
1221+ Rvalue :: Use ( Operand :: Move ( resume_arg. into ( ) ) ) ,
1222+ ) ) ) ,
1223+ } ) ;
12981224 }
12991225
13001226 // Then jump to the real target
0 commit comments