diff options
| author | Ralf Jung <post@ralfj.de> | 2020-08-16 11:08:29 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-09-06 14:14:27 +0200 |
| commit | 720293b6407ad883c609efb6badda990edf59769 (patch) | |
| tree | 8eddae7cd01e46b68f586d7d9c0ad6549666e5f6 /src/test/ui | |
| parent | 6c6003a7ad5e1f03c7c458003bf469d267df5688 (diff) | |
| download | rust-720293b6407ad883c609efb6badda990edf59769.tar.gz rust-720293b6407ad883c609efb6badda990edf59769.zip | |
do not premote non-ZST mutable references ever
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/consts/promotion-mutable-ref.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/consts/promotion-mutable-ref.rs b/src/test/ui/consts/promotion-mutable-ref.rs new file mode 100644 index 00000000000..d6457b3b2c1 --- /dev/null +++ b/src/test/ui/consts/promotion-mutable-ref.rs @@ -0,0 +1,17 @@ +// run-pass +#![feature(const_mut_refs)] + +static mut TEST: i32 = { + // We cannot promote this, as CTFE needs to be able to mutate it later. + let x = &mut [1,2,3]; + x[0] += 1; + x[0] +}; + +// This still works -- it's not done via promotion. +#[allow(unused)] +static mut TEST2: &'static mut [i32] = &mut [0,1,2]; + +fn main() { + assert_eq!(unsafe { TEST }, 2); +} |
