@@ -66,7 +66,6 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
66
66
// We need an `AllCallEdges` pass before we can do any work.
67
67
super :: add_call_guards:: AllCallEdges . run_pass ( tcx, body) ;
68
68
69
- let ( span, arg_count) = ( body. span , body. arg_count ) ;
70
69
let basic_blocks = body. basic_blocks . as_mut ( ) ;
71
70
let local_decls = & body. local_decls ;
72
71
let needs_retag = |place : & Place < ' tcx > | {
@@ -90,20 +89,18 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
90
89
// PART 1
91
90
// Retag arguments at the beginning of the start block.
92
91
{
93
- // FIXME: Consider using just the span covering the function
94
- // argument declaration.
95
- let source_info = SourceInfo :: outermost ( span) ;
96
92
// 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
+
103
100
// Emit their retags.
104
101
basic_blocks[ START_BLOCK ] . statements . splice (
105
102
0 ..0 ,
106
- places. map ( |place| Statement {
103
+ places. map ( |( place, source_info ) | Statement {
107
104
source_info,
108
105
kind : StatementKind :: Retag ( RetagKind :: FnEntry , Box :: new ( place) ) ,
109
106
} ) ,
0 commit comments