Skip to content

Commit 4bf350d

Browse files
committed
add test
1 parent 52830ef commit 4bf350d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![allow(incomplete_features)]
2+
#![feature(const_mut_refs)]
3+
#![feature(adt_const_params)]
4+
5+
struct T<const B: &'static bool>;
6+
7+
impl <const B: &'static bool> T<B> {
8+
const fn set_false(&self) {
9+
unsafe {
10+
*(B as *const bool as *mut bool) = false;
11+
//~^ ERROR evaluation of constant value failed [E0080]
12+
}
13+
}
14+
}
15+
16+
const _: () = {
17+
let x = T::<{&true}>;
18+
x.set_false();
19+
};
20+
21+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/issue-100313.rs:10:13
3+
|
4+
LL | *(B as *const bool as *mut bool) = false;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| writing to alloc7 which is read-only
8+
| inside `T::<&true>::set_false` at $DIR/issue-100313.rs:10:13
9+
...
10+
LL | x.set_false();
11+
| ------------- inside `_` at $DIR/issue-100313.rs:18:5
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)