-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix two variable binding issues in lint let_underscore #119704
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
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.
If you think relying on default_binding_mode
like this is fine, r=me. If you want to change it, then do that and I'll take another look.
compiler/rustc_lint/src/lints.rs
Outdated
@@ -960,10 +961,11 @@ impl AddToDiagnostic for NonBindingLetSub { | |||
rustc_errors::SubdiagnosticMessage, | |||
) -> rustc_errors::SubdiagnosticMessage, | |||
{ | |||
let prefix = if self.default_binding_mode { "" } else { "let " }; |
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.
the comment on default_binding_mode
says
At present, this is false only for destructuring assignment.
I don't like how that doesn't strongly imply that this truly is for destructuring assignment. This makes the code a bit harder to understand and potentially breaks in the future. I'm not sure what the nicest way to address this would be. If you agree.
This is also wrong and broken for non-trivial patterns like (_, _) = (Droppy, Droppy)
, but oh well, those don't even lint today, so Not Your Problem. I'm gonna try fixing these missing lints myself, so I think it's fine to merge this as-is.
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.
update the code to use assign_desugar
, maybe a better choice?
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 pr seems forget to update comments for AssignDesugar
chenyukang@8cf3564
f2b97fd
to
515bd25
Compare
@@ -0,0 +1,21 @@ | |||
// edition: 2021 |
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.
there's a let_underscore_drop subdirectory, let's put it there
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.
that's nicer :)
r=me after moving the test
515bd25
to
75df38e
Compare
@bors r=Nilstrieb |
…re, r=Nilstrieb Fix two variable binding issues in lint let_underscore Fixes rust-lang#119696 Fixes rust-lang#119697
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#118903 (Improved support of collapse_debuginfo attribute for macros.) - rust-lang#119033 (coverage: `llvm-cov` expects column numbers to be bytes, not code points) - rust-lang#119654 (bump bootstrap dependencies) - rust-lang#119660 (remove an unnecessary stderr-per-bitwidth) - rust-lang#119663 (tests: Normalize `\r\n` to `\n` in some run-make tests) - rust-lang#119681 (coverage: Anonymize line numbers in branch views) - rust-lang#119704 (Fix two variable binding issues in lint let_underscore) - rust-lang#119725 (Add helper for when we want to know if an item has a host param) r? `@ghost` `@rustbot` modify labels: rollup
…re, r=Nilstrieb Fix two variable binding issues in lint let_underscore Fixes rust-lang#119696 Fixes rust-lang#119697
…re, r=Nilstrieb Fix two variable binding issues in lint let_underscore Fixes rust-lang#119696 Fixes rust-lang#119697
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#116343 (Stop mentioning internal lang items in no_std binary errors) - rust-lang#118903 (Improved support of collapse_debuginfo attribute for macros.) - rust-lang#119033 (coverage: `llvm-cov` expects column numbers to be bytes, not code points) - rust-lang#119598 (Fix a typo in core::ops::Deref's doc) - rust-lang#119660 (remove an unnecessary stderr-per-bitwidth) - rust-lang#119663 (tests: Normalize `\r\n` to `\n` in some run-make tests) - rust-lang#119681 (coverage: Anonymize line numbers in branch views) - rust-lang#119704 (Fix two variable binding issues in lint let_underscore) - rust-lang#119725 (Add helper for when we want to know if an item has a host param) - rust-lang#119738 (Add `riscv32imafc-esp-espidf` tier 3 target for the ESP32-P4.) - rust-lang#119740 (Remove crossbeam-channel) Failed merges: - rust-lang#119723 (Remove `-Zdont-buffer-diagnostics`.) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#118903 (Improved support of collapse_debuginfo attribute for macros.) - rust-lang#119033 (coverage: `llvm-cov` expects column numbers to be bytes, not code points) - rust-lang#119598 (Fix a typo in core::ops::Deref's doc) - rust-lang#119660 (remove an unnecessary stderr-per-bitwidth) - rust-lang#119663 (tests: Normalize `\r\n` to `\n` in some run-make tests) - rust-lang#119681 (coverage: Anonymize line numbers in branch views) - rust-lang#119704 (Fix two variable binding issues in lint let_underscore) - rust-lang#119725 (Add helper for when we want to know if an item has a host param) - rust-lang#119738 (Add `riscv32imafc-esp-espidf` tier 3 target for the ESP32-P4.) - rust-lang#119740 (Remove crossbeam-channel) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119704 - chenyukang:yukang-fix-let_underscore, r=Nilstrieb Fix two variable binding issues in lint let_underscore Fixes rust-lang#119696 Fixes rust-lang#119697
Improve `let_underscore_lock` - lint if the lock was in a nested pattern - lint if the lock is inside a `Result<Lock, _>` addresses rust-lang#119704 (comment)
Rollup merge of rust-lang#119710 - Nilstrieb:let-_-=-oops, r=TaKO8Ki Improve `let_underscore_lock` - lint if the lock was in a nested pattern - lint if the lock is inside a `Result<Lock, _>` addresses rust-lang#119704 (comment)
Improve `let_underscore_lock` - lint if the lock was in a nested pattern - lint if the lock is inside a `Result<Lock, _>` addresses rust-lang/rust#119704 (comment)
Fixes #119696
Fixes #119697