-
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.
Rollup merge of #77512 - ecstatic-morse:const-checking-allow-abort, r…
…=RalfJung Allow `Abort` terminators in all const-contexts We never unwind during const-eval, so we basically have these semantics already. Also I just figured out that these only appear along the cleanup path, which doesn't get const-checked. In other words, this doesn't actually change behavior: the `check-pass` test I added compiles just fine on nightly. r? @RalfJung cc @rust-lang/wg-const-eval
- Loading branch information
Showing
5 changed files
with
62 additions
and
17 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
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
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,13 @@ | ||
#![feature(unwind_attributes, const_panic)] | ||
|
||
#[unwind(aborts)] | ||
const fn foo() { | ||
panic!() //~ evaluation of constant value failed | ||
} | ||
|
||
const _: () = foo(); //~ any use of this value will cause an error | ||
// Ensure that the CTFE engine handles calls to `#[unwind(aborts)]` gracefully | ||
|
||
fn main() { | ||
let _ = foo(); | ||
} |
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,21 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/unwind-abort.rs:5:5 | ||
| | ||
LL | panic!() | ||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5 | ||
| | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: any use of this value will cause an error | ||
--> $DIR/unwind-abort.rs:8:15 | ||
| | ||
LL | const _: () = foo(); | ||
| --------------^^^^^- | ||
| | | ||
| referenced constant has errors | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
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 @@ | ||
// check-pass | ||
|
||
#![feature(unwind_attributes, const_panic)] | ||
|
||
// `#[unwind(aborts)]` is okay for a `const fn`. We don't unwind in const-eval anyways. | ||
#[unwind(aborts)] | ||
const fn foo() { | ||
panic!() | ||
} | ||
|
||
const fn bar() { | ||
foo(); | ||
} | ||
|
||
fn main() { | ||
bar(); | ||
} |