Skip to content

In save-analysis, enum struct variant constructions aren't being recorded #61385

Description

@est31

Consider this snippet:

enum Foo {
    Bar {
        v: u32,
    },
    Baz(u32),
}
fn main() {
    let v = 31;
    let u = Foo::Bar { v };
}

If you, in vscode, right click onto Foo in enum Foo { to get the places it's referenced, it won't list you any references. Similarly, if you right click on v in let v = 31;, there won't be any references listed. However, both are referenced one line below. Now, if you add let w = Foo::Baz(v);, then the Baz reference will be recorded for both Foo and v. So the problem is that enum struct variant constructor expressions aren't being considered for references.

Thisis no rls bug as the save-analysis by rustc is wrong. If you dump the save-analysis generated for the code above, you'll notice that the refs array is empty while it should contain entries for uses of Foo and the local v variable (as well as the Bar enum variant but that is a separate bug, it doesn't just affect struct variant constructors. See #61302).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-save-analysisArea: saving results of analyses such as inference and borrowck results to a file.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions