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

unnested_or_patterns does not respect clippy.toml msrv #6953

Closed
dtolnay opened this issue Mar 23, 2021 · 0 comments · Fixed by #6977
Closed

unnested_or_patterns does not respect clippy.toml msrv #6953

dtolnay opened this issue Mar 23, 2021 · 0 comments · Fixed by #6977
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dtolnay
Copy link
Member

dtolnay commented Mar 23, 2021

Repro:

# .clippy.toml

msrv = "1.31.0"
// src/main.rs

#![deny(clippy::pedantic)]

enum E {
    A,
    #[allow(dead_code)]
    B,
}

fn main() {
    match E::A {
        e @ E::A | e @ E::B => {
            let _ = e;
        }
    }

    match E::A {
        e @ (E::A | E::B) => {
            let _ = e;
        }
    }
}

cargo clippy emits a unnested_or_patterns lint, despite that syntax not being valid on Rust 1.31.0.

error: unnested or-patterns
  --> src/main.rs:11:9
   |
11 |         e @ E::A | e @ E::B => {
   |         ^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> src/main.rs:1:9
   |
1  | #![deny(clippy::pedantic)]
   |         ^^^^^^^^^^^^^^^^
   = note: `#[deny(clippy::unnested_or_patterns)]` implied by `#[deny(clippy::pedantic)]`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
help: nest the patterns
   |
11 |         e @ (E::A | E::B) => {
   |         ^^^^^^^^^^^^^^^^^

The suggested replacement on Rust 1.31.0:

$ cargo +1.31.0 check
                                             
error: expected one of `)`, `,`, or `::`, found `|`                                       
  --> src/main.rs:11:19                                                                   
   |                                                                                      
11 |         e @ (E::A | E::B) => {                                                       
   |                   ^ expected one of `)`, `,`, or `::` here

Meta

  • cargo clippy -V: clippy 0.1.52 (5d04957 2021-03-22)
  • rustc -Vv:
    rustc 1.53.0-nightly (5d04957a4 2021-03-22)
    binary: rustc
    commit-hash: 5d04957a4b4714f71d38326fc96a0b0ef6dc5800
    commit-date: 2021-03-22
    host: x86_64-unknown-linux-gnu
    release: 1.53.0-nightly
    LLVM version: 12.0.0
    
@dtolnay dtolnay added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Mar 23, 2021
dtolnay added a commit to dtolnay/typetag that referenced this issue Mar 23, 2021
This lint is triggering despite our 1.31.0 msrv in .clippy.toml.
rust-lang/rust-clippy#6953

    error: unnested or-patterns
       --> src/content.rs:688:13
        |
    688 |             s @ Content::String(_) | s @ Content::Str(_) => (s, None),
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `-D clippy::unnested-or-patterns` implied by `-D clippy::pedantic`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns
    help: nest the patterns
        |
    688 |             s @ (Content::String(_) | Content::Str(_)) => (s, None),
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@bors bors closed this as completed in 6f2a6fe Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant