Skip to content

Commit

Permalink
Require or_patterns to suggest nesting them
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroto committed Jun 30, 2020
1 parent ccf7cb3 commit bff6c43
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 bff6c43

Please sign in to comment.