Skip to content

Commit

Permalink
Don't unleash NRVO const-eval test
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed May 17, 2020
1 parent 2fe1170 commit 1deaaa6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// run-pass

// When the NRVO is applied, the return place (`_0`) gets treated like a normal local. For example,
// its address may be taken and it may be written to indirectly. Ensure that MIRI can handle this.

#![feature(const_mut_refs)]

#[inline(never)] // Try to ensure that MIR optimizations don't optimize this away.
const fn init(buf: &mut [u8; 1024]) {
buf[33] = 3;
buf[444] = 4;
}

const fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
const fn nrvo() -> [u8; 1024] {
let mut buf = [0; 1024];
init(&mut buf);
buf
}

// When the NRVO is applied, the return place (`_0`) gets treated like a normal local. For example,
// its address may be taken and it may be written to indirectly. Ensure that MIRI can handle this.
const BUF: [u8; 1024] = nrvo(init);
const BUF: [u8; 1024] = nrvo();

fn main() {
assert_eq!(BUF[33], 3);
Expand Down
27 changes: 0 additions & 27 deletions src/test/ui/consts/miri_unleashed/nrvo.stderr

This file was deleted.

0 comments on commit 1deaaa6

Please sign in to comment.