rust/src/test/ui/borrowck/borrowck-storage-dead.rs

28 lines
353 B
Rust
Raw Normal View History

// compile-flags: -Z borrowck=compare
2017-11-10 05:11:25 -06:00
fn ok() {
loop {
let _x = 1;
}
}
fn also_ok() {
loop {
let _x = String::new();
}
}
2017-11-10 05:11:25 -06:00
fn fail() {
loop {
let x: i32;
let _ = x + 1; //~ERROR (Ast) [E0381]
//~^ ERROR (Mir) [E0381]
}
}
fn main() {
ok();
also_ok();
2017-11-10 05:11:25 -06:00
fail();
}