mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-13 08:27:14 +00:00
Require or_patterns
to suggest nesting them
This commit is contained in:
parent
ccf7cb3764
commit
bff6c435ef
2 changed files with 8 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
6
tests/ui/unnested_or_patterns3.rs
Normal file
6
tests/ui/unnested_or_patterns3.rs
Normal 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) {}
|
||||
}
|
Loading…
Reference in a new issue