Skip to content

Commit d1f0ef5

Browse files
Add explanation of test for validation mismatch
1 parent 8f5494b commit d1f0ef5

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/test/ui/consts/const-eval/issue-65394.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
// Test for absence of validation mismatch ICE in #65394
1+
// This test originated from #65394. We conservatively assume that `x` is still `LiveDrop` even
2+
// after it has been moved because a mutable reference to it exists at some point in the const body.
3+
//
4+
// We will likely have to change this behavior before we allow `&mut` in a `const`.
25

36
const _: Vec<i32> = {
4-
let mut x = Vec::<i32>::new();
7+
let mut x = Vec::<i32>::new(); //~ ERROR destructors cannot be evaluated at compile-time
58
let r = &mut x; //~ ERROR references in constants may only refer to immutable values
69
let y = x;
710
y
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
error[E0017]: references in constants may only refer to immutable values
2-
--> $DIR/issue-65394.rs:5:13
2+
--> $DIR/issue-65394.rs:8:13
33
|
44
LL | let r = &mut x;
55
| ^^^^^^ constants require immutable values
66

7-
[ERROR rustc_mir::transform::qualify_consts] old validator: [($DIR/issue-65394.rs:5:13: 5:19, "MutBorrow(Mut { allow_two_phase_borrow: false })")]
8-
[ERROR rustc_mir::transform::qualify_consts] new validator: [($DIR/issue-65394.rs:5:13: 5:19, "MutBorrow(Mut { allow_two_phase_borrow: false })"), ($DIR/issue-65394.rs:4:9: 4:14, "LiveDrop")]
9-
error: aborting due to previous error
7+
error[E0493]: destructors cannot be evaluated at compile-time
8+
--> $DIR/issue-65394.rs:7:9
9+
|
10+
LL | let mut x = Vec::<i32>::new();
11+
| ^^^^^ constants cannot evaluate destructors
12+
13+
error: aborting due to 2 previous errors
1014

11-
For more information about this error, try `rustc --explain E0017`.
15+
Some errors have detailed explanations: E0017, E0493.
16+
For more information about an error, try `rustc --explain E0017`.

0 commit comments

Comments
 (0)