forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that
const_precise_live_drops
can't be depended upon stably
- Loading branch information
1 parent
1e1257b
commit abc7167
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/test/ui/consts/stable-precise-live-drops-in-libcore.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/consts/stable-precise-live-drops-in-libcore.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 23 additions & 0 deletions
23
src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |