Require or_patterns to suggest nesting them

This commit is contained in:
Eduardo Broto 2020-07-01 00:15:21 +02:00
parent ccf7cb3764
commit bff6c435ef
2 changed files with 8 additions and 2 deletions

View file

@ -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;
}

View file

@ -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) {}
}