Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
est31 opened this issue May 31, 2019 · 1 comment · Fixed by #73248
Closed

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

est31 opened this issue May 31, 2019 · 1 comment · Fixed by #73248
Labels
A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@est31
Copy link
Member

est31 commented May 31, 2019

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).

@Centril Centril added A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-rls C-bug Category: This is a bug. labels May 31, 2019
@Xanewok
Copy link
Member

Xanewok commented May 31, 2019

cc me

Manishearth added a commit to Manishearth/rust that referenced this issue Jun 19, 2020
…ixes, r=Xanewok

save_analysis: improve handling of enum struct variant

Fixes rust-lang#61385
@bors bors closed this as completed in 0e31380 Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants