]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/promotion-mutable-ref.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / src / test / ui / consts / promotion-mutable-ref.rs
CommitLineData
1b1a35ee
XL
1// run-pass
2#![feature(const_mut_refs)]
3
4static 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)]
13static mut TEST2: &'static mut [i32] = &mut [0,1,2];
14
15fn main() {
16 assert_eq!(unsafe { TEST }, 2);
17}