allow rustc_private feature in force-unstable-if-unmarked crates
This commit is contained in:
parent
e96808162a
commit
378049633d
4 changed files with 23 additions and 13 deletions
|
@ -3,6 +3,7 @@
|
||||||
use std::assert_matches::assert_matches;
|
use std::assert_matches::assert_matches;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::num::NonZero;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use rustc_attr::{ConstStability, StabilityLevel};
|
use rustc_attr::{ConstStability, StabilityLevel};
|
||||||
|
@ -789,7 +790,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(ConstStability {
|
Some(ConstStability {
|
||||||
level: StabilityLevel::Unstable { implied_by: implied_feature, .. },
|
level: StabilityLevel::Unstable { implied_by: implied_feature, issue, .. },
|
||||||
feature,
|
feature,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -812,7 +813,23 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
||||||
// to allow this.
|
// to allow this.
|
||||||
let feature_enabled = callee.is_local()
|
let feature_enabled = callee.is_local()
|
||||||
|| tcx.features().enabled(feature)
|
|| tcx.features().enabled(feature)
|
||||||
|| implied_feature.is_some_and(|f| tcx.features().enabled(f));
|
|| implied_feature.is_some_and(|f| tcx.features().enabled(f))
|
||||||
|
|| {
|
||||||
|
// When we're compiling the compiler itself we may pull in
|
||||||
|
// crates from crates.io, but those crates may depend on other
|
||||||
|
// crates also pulled in from crates.io. We want to ideally be
|
||||||
|
// able to compile everything without requiring upstream
|
||||||
|
// modifications, so in the case that this looks like a
|
||||||
|
// `rustc_private` crate (e.g., a compiler crate) and we also have
|
||||||
|
// the `-Z force-unstable-if-unmarked` flag present (we're
|
||||||
|
// compiling a compiler crate), then let this missing feature
|
||||||
|
// annotation slide.
|
||||||
|
// This matches what we do in `eval_stability_allow_unstable` for
|
||||||
|
// regular stability.
|
||||||
|
feature == sym::rustc_private
|
||||||
|
&& issue == NonZero::new(27812)
|
||||||
|
&& self.tcx.sess.opts.unstable_opts.force_unstable_if_unmarked
|
||||||
|
};
|
||||||
// We do *not* honor this if we are in the "danger zone": we have to enforce
|
// We do *not* honor this if we are in the "danger zone": we have to enforce
|
||||||
// recursive const-stability and the callee is not safe-to-expose. In that
|
// recursive const-stability and the callee is not safe-to-expose. In that
|
||||||
// case we need `check_op` to do the check.
|
// case we need `check_op` to do the check.
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enforce_recursive_const_stability(&self) -> bool {
|
pub fn enforce_recursive_const_stability(&self) -> bool {
|
||||||
// We can skip this if neither `staged_api` nor `-Zforrce-unstable-if-unmarked` are enabled,
|
// We can skip this if neither `staged_api` nor `-Zforce-unstable-if-unmarked` are enabled,
|
||||||
// since in such crates `lookup_const_stability` will always be `None`.
|
// since in such crates `lookup_const_stability` will always be `None`.
|
||||||
self.const_kind == Some(hir::ConstContext::ConstFn)
|
self.const_kind == Some(hir::ConstContext::ConstFn)
|
||||||
&& (self.tcx.features().staged_api()
|
&& (self.tcx.features().staged_api()
|
||||||
|
|
|
@ -391,11 +391,6 @@
|
||||||
#![feature(stdarch_internal)]
|
#![feature(stdarch_internal)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
//
|
//
|
||||||
// Library features (crates without staged_api):
|
|
||||||
// tidy-alphabetical-start
|
|
||||||
#![feature(rustc_private)]
|
|
||||||
// tidy-alphabetical-end
|
|
||||||
//
|
|
||||||
// Only for re-exporting:
|
// Only for re-exporting:
|
||||||
// tidy-alphabetical-start
|
// tidy-alphabetical-start
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//@ aux-build:unstable_if_unmarked_const_fn_crate.rs
|
//@ aux-build:unstable_if_unmarked_const_fn_crate.rs
|
||||||
//@ aux-build:unmarked_const_fn_crate.rs
|
//@ aux-build:unmarked_const_fn_crate.rs
|
||||||
#![feature(staged_api, rustc_private)]
|
#![feature(staged_api, rustc_private)]
|
||||||
#![stable(since="1.0.0", feature = "stable")]
|
#![stable(since = "1.0.0", feature = "stable")]
|
||||||
|
|
||||||
extern crate unstable_if_unmarked_const_fn_crate;
|
|
||||||
extern crate unmarked_const_fn_crate;
|
extern crate unmarked_const_fn_crate;
|
||||||
|
extern crate unstable_if_unmarked_const_fn_crate;
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
|
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -18,6 +18,4 @@ const fn stable_fn() {
|
||||||
//~^ERROR: cannot be (indirectly) exposed to stable
|
//~^ERROR: cannot be (indirectly) exposed to stable
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue