-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make it possible to enable const_precise_live_drops per-function
- Loading branch information
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
tests/ui/consts/precise-drop-allow-const-fn-unstable.not_allow.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]: destructor of `Option<T>` cannot be evaluated at compile-time | ||
--> $DIR/precise-drop-allow-const-fn-unstable.rs:11:24 | ||
| | ||
LL | pub const fn unwrap<T>(this: Option<T>) -> T { | ||
| ^^^^ the destructor for this type cannot be evaluated in constant functions | ||
... | ||
LL | } | ||
| - value is dropped here | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0493`. |
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,17 @@ | ||
//@ revisions: allow not_allow | ||
//@ compile-flags: --crate-type=lib -Cinstrument-coverage -Zno-profiler-runtime | ||
//@[allow] check-pass | ||
|
||
#![feature(staged_api, rustc_allow_const_fn_unstable)] | ||
#![stable(feature = "rust_test", since = "1.0.0")] | ||
|
||
#[stable(feature = "rust_test", since = "1.0.0")] | ||
#[rustc_const_stable(feature = "rust_test", since = "1.0.0")] | ||
#[cfg_attr(allow, rustc_allow_const_fn_unstable(const_precise_live_drops))] | ||
pub const fn unwrap<T>(this: Option<T>) -> T { | ||
//[not_allow]~^ ERROR: cannot be evaluated | ||
match this { | ||
Some(x) => x, | ||
None => panic!(), | ||
} | ||
} |