-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Do not lint when range is completely included into another one #6603
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,36 @@ fn overlapping() { | |
_ => (), | ||
} | ||
|
||
match 42 { | ||
5..7 => println!("5 .. 7"), | ||
0..10 => println!("0 .. 10"), | ||
_ => (), | ||
} | ||
|
||
match 42 { | ||
5..10 => println!("5 .. 10"), | ||
0..=10 => println!("0 ... 10"), | ||
_ => (), | ||
} | ||
|
||
match 42 { | ||
0..14 => println!("0 .. 14"), | ||
5..10 => println!("5 .. 10"), | ||
_ => (), | ||
} | ||
Comment on lines
+72
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, shouldn't rustc trigger here? the second arm is unreachable. Well, at least this lint doesn't trigger here. A quick check on Playground shows that rustc triggers here correctly. So I assume this is a late pass lint in rustc and therefore would only trigger once the clippy lint doesn't trigger anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I was a bit surprise too, I was also waiting for an unreachable warning 😅 |
||
|
||
match 42 { | ||
5..14 => println!("5 .. 14"), | ||
0..=10 => println!("0 ... 10"), | ||
_ => (), | ||
} | ||
|
||
match 42 { | ||
0..7 => println!("0 .. 7"), | ||
0..=10 => println!("0 ... 10"), | ||
_ => (), | ||
} | ||
|
||
/* | ||
// FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns | ||
match 42 { | ||
|
Uh oh!
There was an error while loading. Please reload this page.