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.
Rollup merge of rust-lang#56337 - phansch:fix_const_ice, r=oli-obk
Fix const_fn ICE with non-const function pointer Fixes rust-lang#56164
- Loading branch information
Showing
3 changed files
with
165 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(const_fn)] | ||
|
||
const fn foo() { (||{})() } | ||
//~^ ERROR calls in constant functions are limited to constant functions, tuple structs and tuple | ||
// variants | ||
|
||
const fn bad(input: fn()) { | ||
input() | ||
//~^ ERROR function pointers are not allowed in const fn | ||
} | ||
|
||
fn main() { | ||
} |
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,15 @@ | ||
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
--> $DIR/issue-56164.rs:3:18 | ||
| | ||
LL | const fn foo() { (||{})() } | ||
| ^^^^^^^^ | ||
|
||
error: function pointers are not allowed in const fn | ||
--> $DIR/issue-56164.rs:8:5 | ||
| | ||
LL | input() | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0015`. |