Skip to content

Commit f1ad4d6

Browse files
committed
Add inline_const_pat test.
1 parent 65a770c commit f1ad4d6

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Check that we emit an error when an erroneous constant is used in a pattern, even if this
2+
// pattern is uninhabited.
3+
4+
#![feature(never_type)]
5+
#![feature(inline_const_pat)]
6+
//~^ WARN the feature `inline_const_pat` is incomplete
7+
8+
fn foo<T>(x: Result<T, !>) -> T {
9+
match x {
10+
Ok(y) => y,
11+
Err(const { panic!() }) => panic!(),
12+
//~^ ERROR evaluation of `foo::<T>::{constant#0}` failed
13+
}
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
warning: the feature `inline_const_pat` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/const-in-pattern.rs:5:12
3+
|
4+
LL | #![feature(inline_const_pat)]
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0080]: evaluation of `foo::<T>::{constant#0}` failed
11+
--> $DIR/const-in-pattern.rs:11:21
12+
|
13+
LL | Err(const { panic!() }) => panic!(),
14+
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const-in-pattern.rs:11:21
15+
|
16+
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error: aborting due to previous error; 1 warning emitted
19+
20+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)