Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check for overlapping ranges to unreachable patterns lint
- Loading branch information
Showing
11 changed files
with
325 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
//error-pattern: unreachable | ||
//error-pattern: unreachable | ||
//error-pattern: unreachable | ||
//error-pattern: unreachable | ||
//error-pattern: unreachable | ||
|
||
#![deny(unreachable_patterns)] | ||
|
||
fn main() { | ||
match 5 { | ||
1 ..= 10 => { } | ||
5 ..= 6 => { } | ||
5 ..= 6 => { } //~ ERROR multiple patterns covering the same range | ||
_ => {} | ||
}; | ||
|
||
match 5 { | ||
3 ..= 6 => { } | ||
4 ..= 6 => { } | ||
4 ..= 6 => { } //~ ERROR multiple patterns covering the same range | ||
_ => {} | ||
}; | ||
|
||
match 5 { | ||
4 ..= 6 => { } | ||
4 ..= 6 => { } | ||
4 ..= 6 => { } //~ ERROR multiple patterns covering the same range | ||
_ => {} | ||
}; | ||
|
||
match 'c' { | ||
'A' ..= 'z' => {} | ||
'a' ..= 'z' => {} | ||
'a' ..= 'z' => {} //~ ERROR multiple patterns covering the same range | ||
_ => {} | ||
}; | ||
|
||
match 1.0f64 { | ||
0.01f64 ..= 6.5f64 => {} | ||
0.02f64 => {} | ||
//~^ WARNING floating-point types cannot be used in patterns | ||
//~| WARNING floating-point types cannot be used in patterns | ||
//~| WARNING floating-point types cannot be used in patterns | ||
//~| WARNING this was previously accepted by the compiler | ||
//~| WARNING this was previously accepted by the compiler | ||
//~| WARNING this was previously accepted by the compiler | ||
0.02f64 => {} //~ ERROR unreachable pattern | ||
//~^ WARNING floating-point types cannot be used in patterns | ||
//~| WARNING this was previously accepted by the compiler | ||
_ => {} | ||
}; | ||
} |
Oops, something went wrong.