forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#130966 - RalfJung:ptr-metadata-const-stable, r=scottmcm make ptr metadata functions callable from stable const fn So far this was done with a bunch of `rustc_allow_const_fn_unstable`. But those should be the exception, not the norm. If we are confident we can expose the ptr metadata APIs *indirectly* in stable const fn, we should just mark them as `rustc_const_stable`. And we better be confident we can do that since it's already been done a while ago. ;) In particular this marks two intrinsics as const-stable: `aggregate_raw_ptr`, `ptr_metadata`. This should be uncontroversial, they are trivial to implement in the interpreter. Cc `@rust-lang/wg-const-eval` `@rust-lang/lang`
- Loading branch information
Showing
10 changed files
with
77 additions
and
29 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
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(staged_api, rustc_attrs, intrinsics)] | ||
#![stable(since="1.0.0", feature = "stable")] | ||
|
||
extern "rust-intrinsic" { | ||
#[unstable(feature = "unstable", issue = "42")] | ||
#[rustc_const_stable(feature = "stable", since = "1.0.0")] | ||
#[rustc_nounwind] | ||
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize); | ||
} | ||
|
||
#[unstable(feature = "unstable", issue = "42")] | ||
#[rustc_const_stable(feature = "stable", since = "1.0.0")] | ||
pub const fn some_unstable_fn() {} |
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,14 @@ | ||
//@ aux-build:unstable_but_const_stable.rs | ||
|
||
extern crate unstable_but_const_stable; | ||
use unstable_but_const_stable::*; | ||
|
||
fn main() { | ||
some_unstable_fn(); //~ERROR use of unstable library feature | ||
unsafe { write_bytes(4 as *mut u8, 0, 0) }; //~ERROR use of unstable library feature | ||
} | ||
|
||
const fn const_main() { | ||
some_unstable_fn(); //~ERROR use of unstable library feature | ||
unsafe { write_bytes(4 as *mut u8, 0, 0) }; //~ERROR use of unstable library feature | ||
} |
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,43 @@ | ||
error[E0658]: use of unstable library feature 'unstable' | ||
--> $DIR/unstable-const-stable.rs:7:5 | ||
| | ||
LL | some_unstable_fn(); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information | ||
= help: add `#![feature(unstable)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: use of unstable library feature 'unstable' | ||
--> $DIR/unstable-const-stable.rs:8:14 | ||
| | ||
LL | unsafe { write_bytes(4 as *mut u8, 0, 0) }; | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information | ||
= help: add `#![feature(unstable)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: use of unstable library feature 'unstable' | ||
--> $DIR/unstable-const-stable.rs:12:5 | ||
| | ||
LL | some_unstable_fn(); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information | ||
= help: add `#![feature(unstable)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: use of unstable library feature 'unstable' | ||
--> $DIR/unstable-const-stable.rs:13:14 | ||
| | ||
LL | unsafe { write_bytes(4 as *mut u8, 0, 0) }; | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information | ||
= help: add `#![feature(unstable)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |