Auto merge of #132027 - RalfJung:lang-feature-bool-fields, r=nnethercote
nightly feature tracking: get rid of the per-feature bool fields The `struct Features` that tracks which features are enabled has a ton of public `bool`-typed fields that are basically caching the result of looking up the corresponding feature in `enabled_lang_features`. Having public fields with an invariant is not great, so at least they should be made private. However, it turns out caching these lookups is actually [not worth it](https://github.com/rust-lang/rust/pull/131321#issuecomment-2402068336), so this PR just entirely gets rid of these fields. (The alternative would be to make them private and have a method for each of them to expose them in a read-only way. Most of the diff of this PR would be the same in that case.) r? `@nnethercote`
This commit is contained in:
commit
be01dabfef
111 changed files with 324 additions and 385 deletions
|
@ -116,7 +116,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// @lcnr believes that successfully evaluating even though there are
|
||||
// used generic parameters is a bug of evaluation, so checking for it
|
||||
// here does feel somewhat sensible.
|
||||
if !self.features().generic_const_exprs && ct.args.has_non_region_param() {
|
||||
if !self.features().generic_const_exprs() && ct.args.has_non_region_param() {
|
||||
let def_kind = self.def_kind(instance.def_id());
|
||||
assert!(
|
||||
matches!(
|
||||
|
|
|
@ -61,7 +61,7 @@ pub enum OverlapMode {
|
|||
|
||||
impl OverlapMode {
|
||||
pub fn get(tcx: TyCtxt<'_>, trait_id: DefId) -> OverlapMode {
|
||||
let with_negative_coherence = tcx.features().with_negative_coherence;
|
||||
let with_negative_coherence = tcx.features().with_negative_coherence();
|
||||
let strict_coherence = tcx.has_attr(trait_id, sym::rustc_strict_coherence);
|
||||
|
||||
if with_negative_coherence {
|
||||
|
|
|
@ -710,15 +710,15 @@ impl<'tcx> rustc_type_ir::inherent::Safety<TyCtxt<'tcx>> for hir::Safety {
|
|||
|
||||
impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_feature::Features {
|
||||
fn generic_const_exprs(self) -> bool {
|
||||
self.generic_const_exprs
|
||||
self.generic_const_exprs()
|
||||
}
|
||||
|
||||
fn coroutine_clone(self) -> bool {
|
||||
self.coroutine_clone
|
||||
self.coroutine_clone()
|
||||
}
|
||||
|
||||
fn associated_const_equality(self) -> bool {
|
||||
self.associated_const_equality
|
||||
self.associated_const_equality()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
|
|||
),
|
||||
}
|
||||
}
|
||||
ty::Array(inner, len) if tcx.features().transmute_generic_consts => {
|
||||
ty::Array(inner, len) if tcx.features().transmute_generic_consts() => {
|
||||
let len_eval = len.try_to_target_usize(tcx);
|
||||
if len_eval == Some(0) {
|
||||
return Ok(SizeSkeleton::Known(Size::from_bytes(0), None));
|
||||
|
|
|
@ -1208,7 +1208,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
}
|
||||
}
|
||||
|
||||
if self.tcx().features().return_type_notation
|
||||
if self.tcx().features().return_type_notation()
|
||||
&& let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) =
|
||||
self.tcx().opt_rpitit_info(def_id)
|
||||
&& let ty::Alias(_, alias_ty) =
|
||||
|
|
|
@ -750,7 +750,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn new_diverging_default(tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
if tcx.features().never_type_fallback { tcx.types.never } else { tcx.types.unit }
|
||||
if tcx.features().never_type_fallback() { tcx.types.never } else { tcx.types.unit }
|
||||
}
|
||||
|
||||
// lang and diagnostic tys
|
||||
|
|
|
@ -877,8 +877,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// FIXME(effects): This is suspicious and should probably not be done,
|
||||
// especially now that we enforce host effects and then properly handle
|
||||
// effect vars during fallback.
|
||||
let mut host_always_on =
|
||||
!self.features().effects || self.sess.opts.unstable_opts.unleash_the_miri_inside_of_you;
|
||||
let mut host_always_on = !self.features().effects()
|
||||
|| self.sess.opts.unstable_opts.unleash_the_miri_inside_of_you;
|
||||
|
||||
// Compute the constness required by the context.
|
||||
let const_context = self.hir().body_const_context(def_id);
|
||||
|
@ -1826,8 +1826,8 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||
/// cause an ICE that we otherwise may want to prevent.
|
||||
pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
|
||||
if (matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
|
||||
&& tcx.features().intrinsics)
|
||||
|| (tcx.has_attr(def_id, sym::rustc_intrinsic) && tcx.features().rustc_attrs)
|
||||
&& tcx.features().intrinsics())
|
||||
|| (tcx.has_attr(def_id, sym::rustc_intrinsic) && tcx.features().rustc_attrs())
|
||||
{
|
||||
Some(ty::IntrinsicDef {
|
||||
name: tcx.item_name(def_id.into()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue