-
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
Fix extra non_snake_case
warning for shorthand field bindings
#89473
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Oct 2, 2021
FabianWolff
force-pushed
the
issue-89469
branch
from
October 3, 2021 12:33
62bb218
to
9626f2b
Compare
@bors r+ |
📌 Commit 9626f2b has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Oct 4, 2021
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Oct 5, 2021
…lett Fix extra `non_snake_case` warning for shorthand field bindings Fixes rust-lang#89469. The problem is the innermost `if` condition here: https://github.com/rust-lang/rust/blob/d14731cb3ced8318d7fc83cbe838f0e7f2fb3b40/compiler/rustc_lint/src/nonstandard_style.rs#L435-L452 This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Oct 5, 2021
…lett Fix extra `non_snake_case` warning for shorthand field bindings Fixes rust-lang#89469. The problem is the innermost `if` condition here: https://github.com/rust-lang/rust/blob/d14731cb3ced8318d7fc83cbe838f0e7f2fb3b40/compiler/rustc_lint/src/nonstandard_style.rs#L435-L452 This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Oct 5, 2021
…lett Fix extra `non_snake_case` warning for shorthand field bindings Fixes rust-lang#89469. The problem is the innermost `if` condition here: https://github.com/rust-lang/rust/blob/d14731cb3ced8318d7fc83cbe838f0e7f2fb3b40/compiler/rustc_lint/src/nonstandard_style.rs#L435-L452 This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 5, 2021
…ingjubilee Rollup of 15 pull requests Successful merges: - rust-lang#87993 (Stabilize try_reserve) - rust-lang#88090 (Perform type inference in range pattern) - rust-lang#88780 (Added abs_diff for integer types.) - rust-lang#89270 (path.push() should work as expected on windows verbatim paths) - rust-lang#89413 (Correctly handle supertraits for min_specialization) - rust-lang#89456 (Update to the final LLVM 13.0.0 release) - rust-lang#89466 (Fix bug with query modifier parsing) - rust-lang#89473 (Fix extra `non_snake_case` warning for shorthand field bindings) - rust-lang#89474 (rustdoc: Improve doctest pass's name and module's name) - rust-lang#89478 (Fixed numerus of error message) - rust-lang#89480 (Add test for issue 89118.) - rust-lang#89487 (Try to recover from a `=>` -> `=` or `->` typo in a match arm) - rust-lang#89494 (Deny `where` clauses on `auto` traits) - rust-lang#89511 (:arrow_up: rust-analyzer) - rust-lang#89536 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Oct 5, 2021
…lett Fix extra `non_snake_case` warning for shorthand field bindings Fixes rust-lang#89469. The problem is the innermost `if` condition here: https://github.com/rust-lang/rust/blob/d14731cb3ced8318d7fc83cbe838f0e7f2fb3b40/compiler/rustc_lint/src/nonstandard_style.rs#L435-L452 This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #89469. The problem is the innermost
if
condition here:rust/compiler/rustc_lint/src/nonstandard_style.rs
Lines 435 to 452 in d14731c
This code runs for every
PatKind::Binding
, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call toself.check_snake_case()
will indeed be skipped in thecheck_pat()
call forA
; but whencheck_pat()
is called forB
, the loop will still iterate overA
, andfield.ident (= A) != ident (= B)
will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding thatcheck_pat()
was actually called for.