Skip to content

Commit 1084eff

Browse files
committed
Add test for failing try_eval_bits
1 parent 21a0e5d commit 1084eff

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs

+9
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,13 @@ fn main() {
154154
match 0u128 { //~ ERROR non-exhaustive patterns
155155
4 ..= u128::MAX => {}
156156
}
157+
158+
const FOO: i32 = 42;
159+
const BAR: &i32 = &42;
160+
match &0 {
161+
&42 => {}
162+
&FOO => {} //~ ERROR unreachable pattern
163+
BAR => {} // not detected as unreachable because `try_eval_bits` fails on BAR
164+
_ => {}
165+
}
157166
}

src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ LL | match 0u128 {
118118
|
119119
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
120120

121-
error: aborting due to 14 previous errors
121+
error: unreachable pattern
122+
--> $DIR/exhaustive_integer_patterns.rs:162:9
123+
|
124+
LL | &FOO => {}
125+
| ^^^^
126+
127+
error: aborting due to 15 previous errors
122128

123129
For more information about this error, try `rustc --explain E0004`.

0 commit comments

Comments
 (0)