-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![feature(never_type)] | ||
#![feature(exhaustive_patterns)] | ||
#![deny(unreachable_patterns)] | ||
|
||
fn main() {} | ||
|
||
fn foo(nevers: &[!]) { | ||
match nevers { | ||
&[] => (), | ||
}; | ||
|
||
match nevers { | ||
&[] => (), | ||
&[_] => (), //~ ERROR unreachable pattern | ||
&[_, _, ..] => (), //~ ERROR unreachable pattern | ||
}; | ||
|
||
match nevers { | ||
//~^ ERROR non-exhaustive patterns: `&[]` not covered | ||
&[_] => (), //~ ERROR unreachable pattern | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error: unreachable pattern | ||
--> $DIR/slice_of_empty.rs:14:9 | ||
| | ||
LL | &[_] => (), | ||
| ^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/slice_of_empty.rs:3:9 | ||
| | ||
LL | #![deny(unreachable_patterns)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: unreachable pattern | ||
--> $DIR/slice_of_empty.rs:15:9 | ||
| | ||
LL | &[_, _, ..] => (), | ||
| ^^^^^^^^^^^ | ||
|
||
error: unreachable pattern | ||
--> $DIR/slice_of_empty.rs:20:9 | ||
| | ||
LL | &[_] => (), | ||
| ^^^^ | ||
|
||
error[E0004]: non-exhaustive patterns: `&[]` not covered | ||
--> $DIR/slice_of_empty.rs:18:11 | ||
| | ||
LL | match nevers { | ||
| ^^^^^^ pattern `&[]` not covered | ||
| | ||
= note: the matched value is of type `&[!]` | ||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | ||
| | ||
LL | &[_] => (), &[] => todo!(), | ||
| ++++++++++++++++ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0004`. |