-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[WIP] Run the unused variables lint on the MIR #72164
[WIP] Run the unused variables lint on the MIR #72164
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Forgot the r? @ghost. Sorry |
We use it for the RHS of statements like `let _ = x`.
376ab36
to
22eb8f4
Compare
Some more TODOs for myself:
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #69171) made this pull request unmergeable. Please resolve the merge conflicts. |
This will require a lot more work, and I'm still not sure if it's the correct approach. I don't anticipate I'll get back to it anytime soon. |
Resolves #51003.
This removes the HIR liveness pass that is currently responsible for the unused variables lint. The idea is that this will reduce the overall difficulty of updating the HIR. Unfortunately, because we are moving this analysis further away from the AST, we need to do some tricks to map MIR locals back the variables they are tied to. One source of friction is bindings in match patterns, which are simultaneously associated with two distinct locals, one in the guard and one in the match arm body.
Due to a shortcoming of the incremental tests, I cannot add a
HirId
toVarBindingForm
. As a result, we are storing way too much stuff inVarBindingForm
, and properly handling multiple bindings with the same name (e.g.,Ok(x) | Err(x)
) will require more still. I'd like to fix the underlying issue and start storingHirId
s in theVarBindingForm
, but I think this will require changing the problematic tests? Until we can store aHirId
onVarBindingForm
, I likely won't prioritize full diagnostic parity with the HIR liveness pass, since my current approach seems clearly wrong.I don't think it's clear that this approach will be easier to maintain than the HIR liveness analysis. I'm posting this draft so that people can weigh in on that question. If it is resolved in the affirmative, I'll continue working on this, but until then it's not ready for a detailed review.