Limit storage duration of inlined always live locals

This commit is contained in:
Tomasz Miąsko 2020-11-15 00:00:00 +00:00
parent 75042566d1
commit f27d56d1ff
7 changed files with 73 additions and 5 deletions

View file

@ -1,8 +1,8 @@
// edition:2018
// compile-flags: -Z mir-opt-level=2 -Z unsound-mir-opts
// compile-flags: -Z mir-opt-level=2
#[inline(always)]
pub fn f(s: bool) -> String {
pub fn copy_prop(s: bool) -> String {
let a = "Hello world!".to_string();
let b = a;
let c = b;
@ -12,3 +12,9 @@ pub fn f(s: bool) -> String {
String::new()
}
}
#[inline(always)]
pub fn dest_prop(x: &[u8]) -> &[u8] {
let y = &x[..x.len()];
y
}

View file

@ -1,6 +1,8 @@
// Regression test for issue #76375.
//
// edition:2018
// build-pass
// compile-flags: -Z mir-opt-level=2 -L.
// compile-flags: -Z mir-opt-level=2
// aux-build:issue_76375_aux.rs
#![crate_type = "lib"]
@ -8,8 +10,18 @@
extern crate issue_76375_aux;
pub async fn g() {
issue_76375_aux::f(true);
issue_76375_aux::copy_prop(true);
h().await;
}
pub async fn u() {
let b = [0u8; 32];
let mut i = 0;
while i != 10 {
issue_76375_aux::dest_prop(&b);
h().await;
i += 1;
}
}
pub async fn h() {}