Conversation
|
r? @llogiq (rust-highfive has picked a reviewer for you, use r? to override) |
|
About recategorizing: I think we should have some kind of shadow lint on by default as it is a source of bugs. I thought a while ago that we could have a more permissive shadow lint that only lints when the two bindings are unrelated and have the same type. It's more likely you'll get a compiler error than a bug if you confuse two bindings with different types. Maybe you can try this variant? |
|
I like both this simplification and @mikerite's idea of only linting on same-type shadows. It still should be either a pedantic or restriction lint. And perhaps we could reinstate the |
|
I can imagine the same-type lint would be more accurate. Not so much for Clippy since we keep descending the HIR and shadowing Note there is yet another suggestion #3433 for a new shadow lint. I would call that one Here's another idea. We could have one lint called
|
|
The problem with this config usage is that it's one-size-fits all and there is no way to allow(shadow) partially. |
|
Can you give an example? The config seems to give enough control to me. But maybe I need to explain it... The After this PR, you should be able to |
|
How do you configure the items where the lints apply or not? |
|
You can do |
|
But what if I want to allow only some variants in one part of the code and other variants elsewhere? |
|
I guess that level of tweaking just doesn't seem valuable to me. But I understand it would be a slight loss of functionality and that could frustrate users. |
|
☔ The latest upstream changes (presumably #7604) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@camsteffen any news on this PR? What's your plan going forward? |
|
@llogiq thanks for the ping. This has been in the back of my mind. If it's okay with you, I would like to make the shadow lints restriction (just move shadow_unrelated) and leave a possible allow-by-default lint to a future enhancement. |
4ad6803 to
6462ad2
Compare
2665fb1 to
fd942b6
Compare
|
☔ The latest upstream changes (presumably #7673) made this pull request unmergeable. Please resolve the merge conflicts. |
|
r=me after rebase |
|
@bors r=llogic |
|
📌 Commit ac5b02d has been approved by |
Re-write shadow lints changelog: Move shadow_unrelated to restriction changelog: The shadow lints find a lot more shadows and are not limited to certain patterns Drastically simplifies the implementation. Catches a lot more cases. I removed the "initialization happens here" note. It is not helpful IMO. Closes #318 Fixes #2890 Fixes #6563 Fixes #7588 Fixes #7620
|
💔 Test failed - checks-action_test |
|
@bors r=llogic |
|
📌 Commit a17359c has been approved by |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: Move shadow_unrelated to restriction
changelog: The shadow lints find a lot more shadows and are not limited to certain patterns
Drastically simplifies the implementation. Catches a lot more cases.
I removed the "initialization happens here" note. It is not helpful IMO.
Closes #318
Fixes #2890
Fixes #6563
Fixes #7588
Fixes #7620