Add tests
This commit is contained in:
parent
7d3818152d
commit
3c1a1c6227
@ -48,6 +48,22 @@ fn main() {
|
||||
(1 | 1,) => {} //~ ERROR unreachable
|
||||
_ => {}
|
||||
}
|
||||
match 0 {
|
||||
(0 | 1) | 1 => {} //~ ERROR unreachable
|
||||
_ => {}
|
||||
}
|
||||
match 0 {
|
||||
0 | (0 | 0) => {}
|
||||
//~^ ERROR unreachable
|
||||
_ => {}
|
||||
}
|
||||
match None {
|
||||
// There is only one error that correctly points to the whole subpattern
|
||||
Some(0) |
|
||||
Some( //~ ERROR unreachable
|
||||
0 | 0) => {}
|
||||
_ => {}
|
||||
}
|
||||
match [0; 2] {
|
||||
[0
|
||||
| 0 //~ ERROR unreachable
|
||||
|
@ -77,58 +77,77 @@ LL | (1 | 1,) => {}
|
||||
| ^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:52:19
|
||||
|
|
||||
LL | (0 | 1) | 1 => {}
|
||||
| ^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:56:14
|
||||
|
|
||||
LL | 0 | (0 | 0) => {}
|
||||
| ^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:63:13
|
||||
|
|
||||
LL | / Some(
|
||||
LL | | 0 | 0) => {}
|
||||
| |______________________^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:69:15
|
||||
|
|
||||
LL | | 0
|
||||
| ^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:55:15
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:71:15
|
||||
|
|
||||
LL | | 0] => {}
|
||||
| ^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:63:10
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:79:10
|
||||
|
|
||||
LL | [1
|
||||
| ^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:75:10
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:91:10
|
||||
|
|
||||
LL | [true
|
||||
| ^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:82:36
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:98:36
|
||||
|
|
||||
LL | (true | false, None | Some(true
|
||||
| ^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:98:14
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:114:14
|
||||
|
|
||||
LL | Some(0
|
||||
| ^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:117:19
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:133:19
|
||||
|
|
||||
LL | | false) => {}
|
||||
| ^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:125:15
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:141:15
|
||||
|
|
||||
LL | | true) => {}
|
||||
| ^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:131:15
|
||||
--> $DIR/exhaustiveness-unreachable-pattern.rs:147:15
|
||||
|
|
||||
LL | | true,
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
error: aborting due to 24 previous errors
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
#![deny(unreachable_patterns)]
|
||||
//~^ NOTE: lint level is defined here
|
||||
pub enum TypeCtor {
|
||||
Slice,
|
||||
Array,
|
||||
}
|
||||
|
||||
pub struct ApplicationTy(TypeCtor);
|
||||
|
||||
macro_rules! ty_app {
|
||||
($ctor:pat) => {
|
||||
ApplicationTy($ctor) //~ ERROR unreachable pattern
|
||||
};
|
||||
}
|
||||
|
||||
fn _foo(ty: ApplicationTy) {
|
||||
match ty {
|
||||
ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {} //~ NOTE: in this expansion
|
||||
}
|
||||
|
||||
// same as above, with the macro expanded
|
||||
match ty {
|
||||
ApplicationTy(TypeCtor::Array) | ApplicationTy(TypeCtor::Slice) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,18 @@
|
||||
error: unreachable pattern
|
||||
--> $DIR/issue-80501-or-pat-and-macro.rs:12:9
|
||||
|
|
||||
LL | ApplicationTy($ctor)
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {}
|
||||
| ------------------------ in this macro invocation
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-80501-or-pat-and-macro.rs:1:9
|
||||
|
|
||||
LL | #![deny(unreachable_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
x
Reference in New Issue
Block a user