Add tests for `const_precise_live_drops`
This commit is contained in:
parent
9e2ee322e8
commit
2dcf7dbb86
|
@ -0,0 +1,15 @@
|
|||
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`.
|
|
@ -1,11 +1,14 @@
|
|||
// 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 @@ const _: Option<Vec<i32>> = {
|
|||
// 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 @@ const _: Vec<i32> = {
|
|||
// 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 _: Vec<i32> = {
|
|||
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 {
|
|
@ -1,23 +1,23 @@
|
|||
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
|
|
@ -1,7 +1,9 @@
|
|||
// 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>> = {
|
|
@ -0,0 +1,20 @@
|
|||
// 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() {}
|
Loading…
Reference in New Issue