This commit is contained in:
b-naber 2022-08-10 09:58:53 +02:00
parent 52830efdcc
commit 4bf350dc38
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#![allow(incomplete_features)]
#![feature(const_mut_refs)]
#![feature(adt_const_params)]
struct T<const B: &'static bool>;
impl <const B: &'static bool> T<B> {
const fn set_false(&self) {
unsafe {
*(B as *const bool as *mut bool) = false;
//~^ ERROR evaluation of constant value failed [E0080]
}
}
}
const _: () = {
let x = T::<{&true}>;
x.set_false();
};
fn main() {}

View File

@ -0,0 +1,15 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-100313.rs:10:13
|
LL | *(B as *const bool as *mut bool) = false;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| writing to alloc7 which is read-only
| inside `T::<&true>::set_false` at $DIR/issue-100313.rs:10:13
...
LL | x.set_false();
| ------------- inside `_` at $DIR/issue-100313.rs:18:5
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.