Skip to content

MIR inlining doesn't properly adjust SourceScopeData parent_scope fields. #76997

Closed
@eddyb

Description

@eddyb

After MIR inlining, this example (see on godbolt):

fn foo() {
    let f = |x| { let y = x; y };
    f(())
}

produces this scope shape (I've removed all the lets and spans):

    scope 1 {
        debug f => _1;
        scope 2 {
            debug x => _4;
        }
    }
    scope 3 {
        debug y => _3;
    }

You can see x is properly located, in the inlined outermost callee scope (2) as a child of the callsite scope (1).
But y isn't, as its scope (3) keeps the original parent_scope (0) it had in the callee body, pre-inlining.

Will try to fix this as part of #68965, or maybe open a separate PR if I can shuffle the commits around.
cc @rust-lang/wg-mir-opt

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions