File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
src/test/ui/const-generics/issues Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 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 ( ) { }
Original file line number Diff line number Diff line change 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`.
You can’t perform that action at this time.
0 commit comments