@@ -66,7 +66,6 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
6666 // We need an `AllCallEdges` pass before we can do any work.
6767 super :: add_call_guards:: AllCallEdges . run_pass ( tcx, body) ;
6868
69- let ( span, arg_count) = ( body. span , body. arg_count ) ;
7069 let basic_blocks = body. basic_blocks . as_mut ( ) ;
7170 let local_decls = & body. local_decls ;
7271 let needs_retag = |place : & Place < ' tcx > | {
@@ -90,20 +89,18 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
9089 // PART 1
9190 // Retag arguments at the beginning of the start block.
9291 {
93- // FIXME: Consider using just the span covering the function
94- // argument declaration.
95- let source_info = SourceInfo :: outermost ( span) ;
9692 // Gather all arguments, skip return value.
97- let places = local_decls
98- . iter_enumerated ( )
99- . skip ( 1 )
100- . take ( arg_count)
101- . map ( |( local, _) | Place :: from ( local) )
102- . filter ( needs_retag) ;
93+ let places = local_decls. iter_enumerated ( ) . skip ( 1 ) . take ( body. arg_count ) . filter_map (
94+ |( local, decl) | {
95+ let place = Place :: from ( local) ;
96+ needs_retag ( & place) . then_some ( ( place, decl. source_info ) )
97+ } ,
98+ ) ;
99+
103100 // Emit their retags.
104101 basic_blocks[ START_BLOCK ] . statements . splice (
105102 0 ..0 ,
106- places. map ( |place| Statement {
103+ places. map ( |( place, source_info ) | Statement {
107104 source_info,
108105 kind : StatementKind :: Retag ( RetagKind :: FnEntry , Box :: new ( place) ) ,
109106 } ) ,
0 commit comments