2020-06-11 17:08:53 -05:00
|
|
|
// revisions: stock precise
|
|
|
|
|
|
|
|
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
2019-11-17 23:11:42 -06:00
|
|
|
|
2020-06-11 17:08:53 -05:00
|
|
|
// `x` is *not* always moved into the final value and may be dropped inside the initializer.
|
2019-11-17 23:11:42 -06:00
|
|
|
const _: Option<Vec<i32>> = {
|
|
|
|
let y: Option<Vec<i32>> = None;
|
|
|
|
let x = Some(Vec::new());
|
2020-06-11 17:08:53 -05:00
|
|
|
//[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time
|
2019-11-17 23:11:42 -06:00
|
|
|
|
|
|
|
if true {
|
|
|
|
x
|
|
|
|
} else {
|
|
|
|
y
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// We only clear `NeedsDrop` if a local is moved from in entirely. This is a shortcoming of the
|
|
|
|
// existing analysis.
|
|
|
|
const _: Vec<i32> = {
|
|
|
|
let vec_tuple = (Vec::new(),);
|
2020-06-11 17:08:53 -05:00
|
|
|
//[stock]~^ ERROR destructors cannot be evaluated at compile-time
|
2019-11-17 23:11:42 -06:00
|
|
|
|
|
|
|
vec_tuple.0
|
|
|
|
};
|
|
|
|
|
|
|
|
// This applies to single-field enum variants as well.
|
|
|
|
const _: Vec<i32> = {
|
|
|
|
let x: Result<_, Vec<i32>> = Ok(Vec::new());
|
2020-06-11 17:08:53 -05:00
|
|
|
//[stock]~^ ERROR destructors cannot be evaluated at compile-time
|
2019-11-17 23:11:42 -06:00
|
|
|
|
|
|
|
match x {
|
|
|
|
Ok(x) | Err(x) => x,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-10 23:24:46 -06:00
|
|
|
const _: Option<Vec<i32>> = {
|
|
|
|
let mut some = Some(Vec::new());
|
|
|
|
let mut tmp = None;
|
2020-06-11 17:08:53 -05:00
|
|
|
//[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time
|
2019-12-10 23:24:46 -06:00
|
|
|
|
|
|
|
let mut i = 0;
|
|
|
|
while i < 10 {
|
|
|
|
tmp = some;
|
|
|
|
some = None;
|
|
|
|
|
2019-12-11 12:20:50 -06:00
|
|
|
// We can escape the loop with `Some` still in `tmp`,
|
|
|
|
// which would require that it be dropped at the end of the block.
|
2019-12-10 23:24:46 -06:00
|
|
|
if i > 100 {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
some = tmp;
|
|
|
|
tmp = None;
|
|
|
|
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
some
|
|
|
|
};
|
|
|
|
|
2019-11-17 23:11:42 -06:00
|
|
|
fn main() {}
|