Preserve argument indexes when inlining MIR
We store argument indexes on VarDebugInfo. Unlike the previous method of relying on the variable index to know whether a variable is an argument, this survives MIR inlining. We also no longer check if var.source_info.scope is the outermost scope. When a function gets inlined, the arguments to the inner function will no longer be in the outermost scope. What we care about though is whether they were in the outermost scope prior to inlining, which we know by whether we assigned an argument index.
This commit is contained in:
parent
7cd6f55323
commit
a6292676eb
8 changed files with 67 additions and 7 deletions
|
@ -2242,6 +2242,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
name,
|
||||
source_info: debug_source_info,
|
||||
value: VarDebugInfoContents::Place(for_arm_body.into()),
|
||||
argument_index: None,
|
||||
});
|
||||
let locals = if has_guard.0 {
|
||||
let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
|
||||
|
@ -2260,6 +2261,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
name,
|
||||
source_info: debug_source_info,
|
||||
value: VarDebugInfoContents::Place(ref_for_guard.into()),
|
||||
argument_index: None,
|
||||
});
|
||||
LocalsForNode::ForGuard { ref_for_guard, for_arm_body }
|
||||
} else {
|
||||
|
|
|
@ -811,6 +811,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
name,
|
||||
source_info: SourceInfo::outermost(captured_place.var_ident.span),
|
||||
value: VarDebugInfoContents::Place(use_place),
|
||||
argument_index: None,
|
||||
});
|
||||
|
||||
let capture = Capture { captured_place, use_place, mutability };
|
||||
|
@ -827,7 +828,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
expr: &Expr<'tcx>,
|
||||
) -> BlockAnd<()> {
|
||||
// Allocate locals for the function arguments
|
||||
for param in arguments.iter() {
|
||||
for (argument_index, param) in arguments.iter().enumerate() {
|
||||
let source_info =
|
||||
SourceInfo::outermost(param.pat.as_ref().map_or(self.fn_span, |pat| pat.span));
|
||||
let arg_local =
|
||||
|
@ -839,6 +840,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
name,
|
||||
source_info,
|
||||
value: VarDebugInfoContents::Place(arg_local.into()),
|
||||
argument_index: Some(argument_index as u16 + 1),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue