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.
const_eval: Allow std to stabley call const fns from deps.
Because std's dependencies are build with `-Zforce-unstable-if-unmarked` normally, std is unable to call them in const-stable function. However, becuase they had no explicit feature gates, there was no way to use `rustc_allow_const_fn_unstable` to allow this. Therefor we add `#[rustc_allow_const_fn_unstable(any)]` to allow using these functions. The reson to do this is rust-lang#102575, which relies on calling hashbrow function in const-stable std functions.
- Loading branch information
1 parent
5facb42
commit ec12fea
Showing
3 changed files
with
31 additions
and
1 deletion.
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,6 @@ | ||
// compile-flags: -Zforce-unstable-if-unmarked | ||
|
||
// This emulates a dep-of-std (eg hashbrown), that has const functions it | ||
// cannot mark as stable, and is build with force-unstable-if-unmarked. | ||
|
||
pub const fn do_something_else() {} |
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,22 @@ | ||
// aux-build:normal-const-fn.rs | ||
// check-pass | ||
#![crate_type = "lib"] | ||
#![feature(staged_api)] | ||
#![feature(rustc_attrs)] | ||
#![feature(rustc_private)] | ||
#![allow(internal_features)] | ||
#![feature(rustc_allow_const_fn_unstable)] | ||
#![stable(feature = "stable_feature", since = "1.0.0")] | ||
|
||
extern crate normal_const_fn; | ||
|
||
// This ensures std can call const functions in it's deps that don't have | ||
// access to rustc_const_stable annotations (and hense don't have a feature) | ||
// gate. | ||
|
||
#[rustc_const_stable(feature = "stable_feature", since = "1.0.0")] | ||
#[stable(feature = "stable_feature", since = "1.0.0")] | ||
#[rustc_allow_const_fn_unstable(any)] | ||
pub const fn do_something() { | ||
normal_const_fn::do_something_else() | ||
} |