Test that const_precise_live_drops can't be depended upon stably
This commit is contained in:
parent
1e1257b8f8
commit
abc71677da
3 changed files with 57 additions and 0 deletions
22
src/test/ui/consts/stable-precise-live-drops-in-libcore.rs
Normal file
22
src/test/ui/consts/stable-precise-live-drops-in-libcore.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#![stable(feature = "core", since = "1.6.0")]
|
||||
#![feature(staged_api)]
|
||||
#![feature(const_precise_live_drops, const_fn)]
|
||||
|
||||
enum Either<T, S> {
|
||||
Left(T),
|
||||
Right(S),
|
||||
}
|
||||
|
||||
impl<T> Either<T, T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "foo", since = "1.0.0")]
|
||||
pub const fn unwrap(self) -> T {
|
||||
//~^ ERROR destructors cannot be evaluated at compile-time
|
||||
match self {
|
||||
Self::Left(t) => t,
|
||||
Self::Right(t) => t,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/stable-precise-live-drops-in-libcore.rs:13:25
|
||||
|
|
||||
LL | pub const fn unwrap(self) -> T {
|
||||
| ^^^^ constant functions cannot evaluate destructors
|
||||
...
|
||||
LL | }
|
||||
| - value is dropped here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0493`.
|
||||
23
src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs
Normal file
23
src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// check-pass
|
||||
|
||||
#![stable(feature = "core", since = "1.6.0")]
|
||||
#![feature(staged_api)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
|
||||
enum Either<T, S> {
|
||||
Left(T),
|
||||
Right(S),
|
||||
}
|
||||
|
||||
impl<T> Either<T, T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "foo", issue = "none")]
|
||||
pub const fn unwrap(self) -> T {
|
||||
match self {
|
||||
Self::Left(t) => t,
|
||||
Self::Right(t) => t,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue