Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
93 additions
and
6 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
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
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,10 @@ | ||
#![feature(rustc_attrs, staged_api)] | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
const fn error(_: fn()) {} //~ ERROR function pointers in const fn are unstable | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[rustc_allow_const_fn_ptr] | ||
const fn compiles(_: 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,11 @@ | ||
error[E0723]: function pointers in const fn are unstable (see issue #57563) | ||
--> $DIR/allow_const_fn_ptr.rs:4:16 | ||
| | ||
LL | const fn error(_: fn()) {} | ||
| ^ | ||
| | ||
= help: add #![feature(const_fn)] to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0723`. |
11 changes: 11 additions & 0 deletions
11
src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.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,11 @@ | ||
#![feature(staged_api)] | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
const fn error(_: fn()) {} | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[rustc_allow_const_fn_ptr] | ||
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved | ||
const fn compiles(_: fn()) {} | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.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[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics | ||
--> $DIR/allow_const_fn_ptr_feature_gate.rs:7:3 | ||
| | ||
LL | #[rustc_allow_const_fn_ptr] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/29642 | ||
= help: add #![feature(rustc_attrs)] to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
18 changes: 18 additions & 0 deletions
18
src/test/ui/consts/min_const_fn/allow_const_fn_ptr_run_pass.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,18 @@ | ||
// run-pass | ||
|
||
#![feature(rustc_attrs, staged_api)] | ||
#![stable(feature = "rust1", since = "1.0.0")] | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[rustc_allow_const_fn_ptr] | ||
const fn takes_fn_ptr(_: fn()) {} | ||
|
||
const FN: fn() = || (); | ||
|
||
const fn gives_fn_ptr() { | ||
takes_fn_ptr(FN) | ||
} | ||
|
||
fn main() { | ||
gives_fn_ptr(); | ||
} |