-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove HasLocalDecls
.
#129681
Remove HasLocalDecls
.
#129681
Conversation
It's a trait that lets you pass any of `Body`, `LocalDecls`, or `IndexVec<Local, LocalDecl>` to various functions. A minor convenience, and a minor obfuscation, that not actually needed. This commit removes the trait and changes those functions to receive `&LocalDecls` instead of `&D where D: HasLocalDecls`. This makes lots of call sites slightly more verbose, but I think it's worth it for the overall simplicity.
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes lots of call sites slightly more verbose, but I think it's worth it for the overall simplicity.
I disagree that this is worthwhile, and I think this existing abstraction improves code readability significantly in dense MIR like MIR typeck.
If you think this is making folks confused about what to pass in the argument, then I'd suggest leaving a doc comment on HasLocalDecls
saying what implements it.
I'm happy to review this, but since I'm not actually on compiler contributors I think I'm poorly positioned to make a policy decision here on whether this is desirable, so I'll leave this to the team to talk about approach first. |
My original motivation was I had a chang (not in this PR) where a call to @scottmcm: I asked you for review because you modified some of this code in #109819, though I guess that was part of a larger change. |
We discussed in the weekly triage meeting but did not come to a consensus that the changes in this PR were more understandable than the current code. There seemed to be strong support for documenting how to deal with the borrowck error @nnethercote originally ran into in the doc comments for |
@nnethercote TBH I'm generally personally opposed to things like the "into trick", and thus have no issues with this change, I just feel like deciding that for rustc is outside my purview. I only added the new
|
It's a trait that lets you pass any of
Body
,LocalDecls
, orIndexVec<Local, LocalDecl>
to various functions. A minor convenience, and a minor obfuscation, that not actually needed.This commit removes the trait and changes those functions to receive
&LocalDecls
instead of&D where D: HasLocalDecls
. This makes lots of call sites slightly more verbose, but I think it's worth it for the overall simplicity.r? @scottmcm