Skip to content

Commit

Permalink
Auto merge of rust-lang#5758 - ebroto:5704_unnested_or_pats, r=flip1995
Browse files Browse the repository at this point in the history
Require `or_patterns` to suggest nesting them

changelog: Require `#![feature(or_patterns)]` to trigger [`unnested_or_patterns`]

Fixes rust-lang#5704
  • Loading branch information
bors committed Jun 30, 2020
2 parents d05d6ab + bff6c43 commit 36b7983
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/unnested_or_patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl EarlyLintPass for UnnestedOrPatterns {
}

fn lint_unnested_or_patterns(cx: &EarlyContext<'_>, pat: &Pat) {
if !cx.sess.opts.unstable_features.is_nightly_build() {
// User cannot do `#![feature(or_patterns)]`, so bail.
if !cx.sess.features_untracked().or_patterns {
// Do not suggest nesting the patterns if the feature `or_patterns` is not enabled.
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/ui/unnested_or_patterns3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![warn(clippy::unnested_or_patterns)]

// Test that `unnested_or_patterns` does not trigger without enabling `or_patterns`
fn main() {
if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {}
}

0 comments on commit 36b7983

Please sign in to comment.