@@ -261,7 +261,7 @@ impl TransformVisitor<'tcx> {
261261
262262 let self_place = Place :: from ( SELF_ARG ) ;
263263 let assign = Statement {
264- source_info : source_info ( body) ,
264+ source_info : SourceInfo :: outermost ( body. span ) ,
265265 kind : StatementKind :: Assign ( box ( temp, Rvalue :: Discriminant ( self_place) ) ) ,
266266 } ;
267267 ( assign, temp)
@@ -395,7 +395,7 @@ fn replace_local<'tcx>(
395395 body : & mut Body < ' tcx > ,
396396 tcx : TyCtxt < ' tcx > ,
397397) -> Local {
398- let source_info = source_info ( body) ;
398+ let source_info = SourceInfo :: outermost ( body. span ) ;
399399 let new_decl = LocalDecl {
400400 mutability : Mutability :: Mut ,
401401 ty,
@@ -784,7 +784,7 @@ fn insert_switch<'tcx>(
784784 targets : cases. iter ( ) . map ( |& ( _, d) | d) . chain ( iter:: once ( default_block) ) . collect ( ) ,
785785 } ;
786786
787- let source_info = source_info ( body) ;
787+ let source_info = SourceInfo :: outermost ( body. span ) ;
788788 body. basic_blocks_mut ( ) . raw . insert (
789789 0 ,
790790 BasicBlockData {
@@ -858,7 +858,7 @@ fn create_generator_drop_shim<'tcx>(
858858 let mut body = body. clone ( ) ;
859859 body. arg_count = 1 ; // make sure the resume argument is not included here
860860
861- let source_info = source_info ( & body) ;
861+ let source_info = SourceInfo :: outermost ( body. span ) ;
862862
863863 let mut cases = create_cases ( & mut body, transform, Operation :: Drop ) ;
864864
@@ -922,7 +922,7 @@ fn create_generator_drop_shim<'tcx>(
922922}
923923
924924fn insert_term_block < ' tcx > ( body : & mut Body < ' tcx > , kind : TerminatorKind < ' tcx > ) -> BasicBlock {
925- let source_info = source_info ( body) ;
925+ let source_info = SourceInfo :: outermost ( body. span ) ;
926926 body. basic_blocks_mut ( ) . push ( BasicBlockData {
927927 statements : Vec :: new ( ) ,
928928 terminator : Some ( Terminator { source_info, kind } ) ,
@@ -948,7 +948,7 @@ fn insert_panic_block<'tcx>(
948948 cleanup : None ,
949949 } ;
950950
951- let source_info = source_info ( body) ;
951+ let source_info = SourceInfo :: outermost ( body. span ) ;
952952 body. basic_blocks_mut ( ) . push ( BasicBlockData {
953953 statements : Vec :: new ( ) ,
954954 terminator : Some ( Terminator { source_info, kind : term } ) ,
@@ -1025,7 +1025,7 @@ fn create_generator_resume_function<'tcx>(
10251025
10261026 // Poison the generator when it unwinds
10271027 if can_unwind {
1028- let source_info = source_info ( body) ;
1028+ let source_info = SourceInfo :: outermost ( body. span ) ;
10291029 let poison_block = body. basic_blocks_mut ( ) . push ( BasicBlockData {
10301030 statements : vec ! [ transform. set_discr( VariantIdx :: new( POISONED ) , source_info) ] ,
10311031 terminator : Some ( Terminator { source_info, kind : TerminatorKind :: Resume } ) ,
@@ -1092,10 +1092,6 @@ fn create_generator_resume_function<'tcx>(
10921092 dump_mir ( tcx, None , "generator_resume" , & 0 , source, body, |_, _| Ok ( ( ) ) ) ;
10931093}
10941094
1095- fn source_info ( body : & Body < ' _ > ) -> SourceInfo {
1096- SourceInfo { span : body. span , scope : OUTERMOST_SOURCE_SCOPE }
1097- }
1098-
10991095fn insert_clean_drop ( body : & mut Body < ' _ > ) -> BasicBlock {
11001096 let return_block = insert_term_block ( body, TerminatorKind :: Return ) ;
11011097
@@ -1104,7 +1100,7 @@ fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock {
11041100 target : return_block,
11051101 unwind : None ,
11061102 } ;
1107- let source_info = source_info ( body) ;
1103+ let source_info = SourceInfo :: outermost ( body. span ) ;
11081104
11091105 // Create a block to destroy an unresumed generators. This can only destroy upvars.
11101106 body. basic_blocks_mut ( ) . push ( BasicBlockData {
@@ -1135,7 +1131,7 @@ fn create_cases<'tcx>(
11351131 transform : & TransformVisitor < ' tcx > ,
11361132 operation : Operation ,
11371133) -> Vec < ( usize , BasicBlock ) > {
1138- let source_info = source_info ( body) ;
1134+ let source_info = SourceInfo :: outermost ( body. span ) ;
11391135
11401136 transform
11411137 . suspension_points
@@ -1241,7 +1237,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
12411237 replace_local ( resume_local, body. local_decls [ resume_local] . ty , body, tcx) ;
12421238
12431239 // When first entering the generator, move the resume argument into its new local.
1244- let source_info = source_info ( body) ;
1240+ let source_info = SourceInfo :: outermost ( body. span ) ;
12451241 let stmts = & mut body. basic_blocks_mut ( ) [ BasicBlock :: new ( 0 ) ] . statements ;
12461242 stmts. insert (
12471243 0 ,
0 commit comments