Skip to content

Commit abc7167

Browse files
Test that const_precise_live_drops can't be depended upon stably
1 parent 1e1257b commit abc7167

3 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![stable(feature = "core", since = "1.6.0")]
2+
#![feature(staged_api)]
3+
#![feature(const_precise_live_drops, const_fn)]
4+
5+
enum Either<T, S> {
6+
Left(T),
7+
Right(S),
8+
}
9+
10+
impl<T> Either<T, T> {
11+
#[stable(feature = "rust1", since = "1.0.0")]
12+
#[rustc_const_stable(feature = "foo", since = "1.0.0")]
13+
pub const fn unwrap(self) -> T {
14+
//~^ ERROR destructors cannot be evaluated at compile-time
15+
match self {
16+
Self::Left(t) => t,
17+
Self::Right(t) => t,
18+
}
19+
}
20+
}
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0493]: destructors cannot be evaluated at compile-time
2+
--> $DIR/stable-precise-live-drops-in-libcore.rs:13:25
3+
|
4+
LL | pub const fn unwrap(self) -> T {
5+
| ^^^^ constant functions cannot evaluate destructors
6+
...
7+
LL | }
8+
| - value is dropped here
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0493`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
3+
#![stable(feature = "core", since = "1.6.0")]
4+
#![feature(staged_api)]
5+
#![feature(const_precise_live_drops)]
6+
7+
enum Either<T, S> {
8+
Left(T),
9+
Right(S),
10+
}
11+
12+
impl<T> Either<T, T> {
13+
#[stable(feature = "rust1", since = "1.0.0")]
14+
#[rustc_const_unstable(feature = "foo", issue = "none")]
15+
pub const fn unwrap(self) -> T {
16+
match self {
17+
Self::Left(t) => t,
18+
Self::Right(t) => t,
19+
}
20+
}
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)