Skip to content

Commit d41c8d3

Browse files
committed
Add test for passing promotion but failing compilation
1 parent 1530fe0 commit d41c8d3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ignore-compare-mode-nll
2+
// compile-flags: -Z borrowck=migrate
3+
// build-fail
4+
#![feature(const_in_array_repeat_expressions, const_panic, const_fn)]
5+
#![allow(warnings)]
6+
7+
// Some type that is not copyable.
8+
struct Bar;
9+
10+
const fn bad_bar() -> Bar { panic!() }
11+
//~^ ERROR evaluation of constant value failed
12+
13+
fn main() {
14+
let arr: [Bar; 2] = [bad_bar(); 2];
15+
//~^ ERROR erroneous constant used
16+
//~| ERROR evaluation of constant expression failed
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/migrate-fail2.rs:10:29
3+
|
4+
LL | const fn bad_bar() -> Bar { panic!() }
5+
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/migrate-fail2.rs:10:29
6+
|
7+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0080]: evaluation of constant expression failed
10+
--> $DIR/migrate-fail2.rs:14:25
11+
|
12+
LL | let arr: [Bar; 2] = [bad_bar(); 2];
13+
| ^---------^^^^
14+
| |
15+
| referenced constant has errors
16+
17+
error: erroneous constant used
18+
--> $DIR/migrate-fail2.rs:14:25
19+
|
20+
LL | let arr: [Bar; 2] = [bad_bar(); 2];
21+
| ^^^^^^^^^^^^^^ referenced constant has errors
22+
|
23+
= note: `#[deny(const_err)]` on by default
24+
25+
error: aborting due to 3 previous errors
26+
27+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)