Skip to content

fix(lint): don't suggest refutable patterns to "fix" irrefutable bind #89314

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Sep 28, 2021

In function arguments and let bindings, do not suggest changing C to Foo::C unless C is the only variant of Foo, because it won't work.

The general warning is still kept, because code like this is confusing.

Fixes #88730

p.s. src/test/ui/lint/lint-uppercase-variables.rs already tests the one-variant case.

@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 28, 2021
@notriddle notriddle force-pushed the notriddle/lint-fix-enum-variant-match branch from 3d4ccfb to f514884 Compare September 28, 2021 00:23
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 28, 2021

📌 Commit f5148848e579836251720804a5b3725cd8772d5a has been approved by davidtwco

@bors 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 Sep 28, 2021
@bors
Copy link
Collaborator

bors commented Sep 29, 2021

☔ The latest upstream changes (presumably #88950) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 29, 2021
In function arguments and let bindings, do not suggest changing `C` to `Foo::C`
unless `C` is the only variant of `Foo`, because it won't work.

The general warning is still kept, because code like this is confusing.

Fixes rust-lang#88730
@notriddle notriddle force-pushed the notriddle/lint-fix-enum-variant-match branch from f514884 to 6e973f0 Compare September 29, 2021 16:15
@notriddle
Copy link
Contributor Author

@davidtwco I had to rebase this, because some pattern matching machinery changed.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 29, 2021

📌 Commit 6e973f0 has been approved by davidtwco

@bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 29, 2021
ehuss added a commit to ehuss/rust that referenced this pull request Sep 30, 2021
…ariant-match, r=davidtwco

fix(lint): don't suggest refutable patterns to "fix" irrefutable bind

In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work.

The general warning is still kept, because code like this is confusing.

Fixes rust-lang#88730

p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.
Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 30, 2021
…ariant-match, r=davidtwco

fix(lint): don't suggest refutable patterns to "fix" irrefutable bind

In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work.

The general warning is still kept, because code like this is confusing.

Fixes rust-lang#88730

p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.
Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 30, 2021
…ariant-match, r=davidtwco

fix(lint): don't suggest refutable patterns to "fix" irrefutable bind

In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work.

The general warning is still kept, because code like this is confusing.

Fixes rust-lang#88730

p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 1, 2021
…arth

Rollup of 8 pull requests

Successful merges:

 - rust-lang#88782 (Fix ICE when `start` lang item has wrong generics)
 - rust-lang#89202 (Resolve infered types when complaining about unexpected call type )
 - rust-lang#89248 (Suggest similarly named associated items in trait impls)
 - rust-lang#89303 (Add `#[must_not_suspend]` to some types in std)
 - rust-lang#89306 (thread: implements available_concurrency on haiku)
 - rust-lang#89314 (fix(lint): don't suggest refutable patterns to "fix" irrefutable bind)
 - rust-lang#89370 (CTFE: tweak aggregate rvalue handling)
 - rust-lang#89392 (bootstrap: Update comment in config.library.toml.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fbc67b5 into rust-lang:master Oct 1, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 1, 2021
@notriddle notriddle deleted the notriddle/lint-fix-enum-variant-match branch October 1, 2021 06:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bindings_with_variant_name is unhelpful and incorrect for function arguments
5 participants