Skip to content
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

FP redundant_pattern (breaks code), "ref" cannot be omitted #5271

Closed
matthiaskrgr opened this issue Mar 5, 2020 · 0 comments · Fixed by #5287
Closed

FP redundant_pattern (breaks code), "ref" cannot be omitted #5271

matthiaskrgr opened this issue Mar 5, 2020 · 0 comments · Fixed by #5287
Assignees
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

warning: the `s @ _` pattern can be written as just `s`
    --> src/librustc_resolve/imports.rs:1435:25
     |
1435 |                         ref s @ _ => bug!("unexpected import subclass {:?}", s),
     |                         ^^^^^^^^^ help: try: `s`
     |
     = note: `#[warn(clippy::redundant_pattern)]` on by default
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern

using just s broke the build:

error[E0507]: cannot move out of `directive.subclass` which is behind a shared reference
    --> src/librustc_resolve/imports.rs:1415:37
     |
1415 |                     let msg = match directive.subclass {
     |                                     ^^^^^^^^^^^^^^^^^^ help: consider borrowing here: `&directive.subclass`
...
1435 |                         s => bug!("unexpected import subclass {:?}", s),
     |                         -
     |                         |
     |                         data moved here
     |                         move occurs because `s` has type `imports::ImportDirectiveSubclass<'_>`, which does not implement the `Copy` trait

error: aborting due to previous error

For more information about this error, try `rustc --explain E0507`.

it needs to be ref s

@matthiaskrgr matthiaskrgr added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Mar 5, 2020
@matthiaskrgr matthiaskrgr changed the title FP redundant_pattern (breaks code) FP redundant_pattern (breaks code), "ref" cannot be omitted Mar 5, 2020
@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Mar 5, 2020
@matthiaskrgr matthiaskrgr self-assigned this Mar 8, 2020
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Mar 8, 2020
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue Mar 8, 2020
bors added a commit that referenced this issue Mar 9, 2020
redundant_pattern: take binding (ref, ref mut) into account in suggestion

fixes #5271

changelog: redundant_pattern: take binding (ref, ref mut) into account in suggestion (#5271)
@bors bors closed this as completed in 75a2300 Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants