]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/promotion-mutable-ref.rs
Rollup merge of #106718 - lcnr:solver-cycles, r=compiler-errors
[rust.git] / tests / ui / consts / promotion-mutable-ref.rs
1 // run-pass
2 #![feature(const_mut_refs)]
3
4 static mut TEST: i32 = {
5     // We must not promote this, as CTFE needs to be able to mutate it later.
6     let x = &mut [1,2,3];
7     x[0] += 1;
8     x[0]
9 };
10
11 // This still works -- it's not done via promotion.
12 #[allow(unused)]
13 static mut TEST2: &'static mut [i32] = &mut [0,1,2];
14
15 fn main() {
16     assert_eq!(unsafe { TEST }, 2);
17 }