Skip to content

Commit dbf3fba

Browse files
committed
allow rustc_private feature in force-unstable-if-unmarked crates
1 parent 96f9ada commit dbf3fba

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

Diff for: compiler/rustc_const_eval/src/check_consts/check.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::assert_matches::assert_matches;
44
use std::borrow::Cow;
55
use std::mem;
6+
use std::num::NonZero;
67
use std::ops::Deref;
78

89
use rustc_attr::{ConstStability, StabilityLevel};
@@ -780,7 +781,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
780781
}
781782
}
782783
Some(ConstStability {
783-
level: StabilityLevel::Unstable { implied_by: implied_feature, .. },
784+
level: StabilityLevel::Unstable { implied_by: implied_feature, issue, .. },
784785
feature,
785786
..
786787
}) => {
@@ -803,7 +804,23 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
803804
// to allow this.
804805
let feature_enabled = callee.is_local()
805806
|| tcx.features().enabled(feature)
806-
|| implied_feature.is_some_and(|f| tcx.features().enabled(f));
807+
|| implied_feature.is_some_and(|f| tcx.features().enabled(f))
808+
|| {
809+
// When we're compiling the compiler itself we may pull in
810+
// crates from crates.io, but those crates may depend on other
811+
// crates also pulled in from crates.io. We want to ideally be
812+
// able to compile everything without requiring upstream
813+
// modifications, so in the case that this looks like a
814+
// `rustc_private` crate (e.g., a compiler crate) and we also have
815+
// the `-Z force-unstable-if-unmarked` flag present (we're
816+
// compiling a compiler crate), then let this missing feature
817+
// annotation slide.
818+
// This matches what we do in `eval_stability_allow_unstable` for
819+
// regular stability.
820+
feature == sym::rustc_private
821+
&& issue == NonZero::new(27812)
822+
&& self.tcx.sess.opts.unstable_opts.force_unstable_if_unmarked
823+
};
807824
// We do *not* honor this if we are in the "danger zone": we have to enforce
808825
// recursive const-stability and the callee is not safe-to-expose. In that
809826
// case we need `check_op` to do the check.

Diff for: library/std/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,6 @@
392392
#![feature(stdarch_internal)]
393393
// tidy-alphabetical-end
394394
//
395-
// Library features (crates without staged_api):
396-
// tidy-alphabetical-start
397-
#![feature(rustc_private)]
398-
// tidy-alphabetical-end
399-
//
400395
// Only for re-exporting:
401396
// tidy-alphabetical-start
402397
#![feature(assert_matches)]

Diff for: tests/ui/consts/min_const_fn/recursive_const_stab_unmarked_crate_imports.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//@ aux-build:unstable_if_unmarked_const_fn_crate.rs
22
//@ aux-build:unmarked_const_fn_crate.rs
33
#![feature(staged_api, rustc_private)]
4-
#![stable(since="1.0.0", feature = "stable")]
4+
#![stable(since = "1.0.0", feature = "stable")]
55

6-
extern crate unstable_if_unmarked_const_fn_crate;
76
extern crate unmarked_const_fn_crate;
7+
extern crate unstable_if_unmarked_const_fn_crate;
88

99
#[stable(feature = "rust1", since = "1.0.0")]
1010
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
@@ -18,6 +18,4 @@ const fn stable_fn() {
1818
//~^ERROR: cannot be (indirectly) exposed to stable
1919
}
2020

21-
fn main() {
22-
23-
}
21+
fn main() {}

0 commit comments

Comments
 (0)