提交 2dcf7dbb 编写于 作者: D Dylan MacKenzie

Add tests for `const_precise_live_drops`

上级 9e2ee322
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:10:9
|
LL | let x = Some(Vec::new());
| ^ constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:41:9
|
LL | let mut tmp = None;
| ^^^^^^^ constants cannot evaluate destructors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0493`.
// revisions: stock precise
#![feature(const_if_match)]
#![feature(const_loop)]
#![cfg_attr(precise, feature(const_precise_live_drops))]
// `x` is *not* always moved into the final value may be dropped inside the initializer.
// `x` is *not* always moved into the final value and may be dropped inside the initializer.
const _: Option<Vec<i32>> = {
let y: Option<Vec<i32>> = None;
let x = Some(Vec::new());
//~^ ERROR destructors cannot be evaluated at compile-time
//[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time
if true {
x
......@@ -18,7 +21,7 @@
// existing analysis.
const _: Vec<i32> = {
let vec_tuple = (Vec::new(),);
//~^ ERROR destructors cannot be evaluated at compile-time
//[stock]~^ ERROR destructors cannot be evaluated at compile-time
vec_tuple.0
};
......@@ -26,7 +29,7 @@
// This applies to single-field enum variants as well.
const _: Vec<i32> = {
let x: Result<_, Vec<i32>> = Ok(Vec::new());
//~^ ERROR destructors cannot be evaluated at compile-time
//[stock]~^ ERROR destructors cannot be evaluated at compile-time
match x {
Ok(x) | Err(x) => x,
......@@ -36,7 +39,7 @@
const _: Option<Vec<i32>> = {
let mut some = Some(Vec::new());
let mut tmp = None;
//~^ ERROR destructors cannot be evaluated at compile-time
//[stock,precise]~^ ERROR destructors cannot be evaluated at compile-time
let mut i = 0;
while i < 10 {
......
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-failure.rs:7:9
--> $DIR/drop-fail.rs:10:9
|
LL | let x = Some(Vec::new());
| ^ constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-failure.rs:20:9
--> $DIR/drop-fail.rs:23:9
|
LL | let vec_tuple = (Vec::new(),);
| ^^^^^^^^^ constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-failure.rs:28:9
--> $DIR/drop-fail.rs:31:9
|
LL | let x: Result<_, Vec<i32>> = Ok(Vec::new());
| ^ constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-failure.rs:38:9
--> $DIR/drop-fail.rs:41:9
|
LL | let mut tmp = None;
| ^^^^^^^ constants cannot evaluate destructors
......
// run-pass
// revisions: stock precise
#![feature(const_if_match)]
#![feature(const_loop)]
#![cfg_attr(precise, feature(const_precise_live_drops))]
// `x` is always moved into the final value and is not dropped inside the initializer.
const _: Option<Vec<i32>> = {
......
// run-pass
// gate-test-const_precise_live_drops
#![feature(const_if_match)]
#![feature(const_loop)]
#![feature(const_precise_live_drops)]
const _: Vec<i32> = {
let vec_tuple = (Vec::new(),);
vec_tuple.0
};
const _: Vec<i32> = {
let x: Result<_, Vec<i32>> = Ok(Vec::new());
match x {
Ok(x) | Err(x) => x,
}
};
fn main() {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册