From 53fe37de2e11537bf2953a29df3c5be8a8858850 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 4 Oct 2023 09:51:03 +1100 Subject: Remove unused `Span` from the `set` function in `State::Active`. --- compiler/rustc_feature/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_feature/src/lib.rs') diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index 69e33115922..b4933d6339c 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -23,14 +23,14 @@ mod removed; #[cfg(test)] mod tests; -use rustc_span::{edition::Edition, symbol::Symbol, Span}; +use rustc_span::{edition::Edition, symbol::Symbol}; use std::fmt; use std::num::NonZeroU32; #[derive(Clone, Copy)] pub enum State { Accepted, - Active { set: fn(&mut Features, Span) }, + Active { set: fn(&mut Features) }, Removed { reason: Option<&'static str> }, Stabilized { reason: Option<&'static str> }, } -- cgit 1.4.1-3-g733a5 From 1ddb2872ddeb5d56f7bdecfd4175fb13fc510069 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 4 Oct 2023 14:54:12 +1100 Subject: Streamline `find_lang_feature_issue`. It currently processes `ACTIVE_FEATURES` separately from `ACCEPTED_FEATURES`, `REMOVED_FEATURES`, and `STABLE_REMOVED_FEATURES`, for no good reason. This commit treats them uniformly. --- compiler/rustc_feature/src/lib.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'compiler/rustc_feature/src/lib.rs') diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index b4933d6339c..d4dc5920bec 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -79,8 +79,8 @@ pub enum UnstableFeatures { impl UnstableFeatures { /// This takes into account `RUSTC_BOOTSTRAP`. /// - /// If `krate` is [`Some`], then setting `RUSTC_BOOTSTRAP=krate` will enable the nightly features. - /// Otherwise, only `RUSTC_BOOTSTRAP=1` will work. + /// If `krate` is [`Some`], then setting `RUSTC_BOOTSTRAP=krate` will enable the nightly + /// features. Otherwise, only `RUSTC_BOOTSTRAP=1` will work. pub fn from_environment(krate: Option<&str>) -> Self { // `true` if this is a feature-staged build, i.e., on the beta or stable channel. let disable_unstable_features = @@ -107,19 +107,18 @@ impl UnstableFeatures { } fn find_lang_feature_issue(feature: Symbol) -> Option { - if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.name == feature) { - info.issue - } else { - // search in Accepted, Removed, or Stable Removed features - let found = ACCEPTED_FEATURES - .iter() - .chain(REMOVED_FEATURES) - .chain(STABLE_REMOVED_FEATURES) - .find(|t| t.name == feature); - match found { - Some(found) => found.issue, - None => panic!("feature `{feature}` is not declared anywhere"), - } + // Search in all the feature lists. + let found = [] + .iter() + .chain(ACTIVE_FEATURES) + .chain(ACCEPTED_FEATURES) + .chain(REMOVED_FEATURES) + .chain(STABLE_REMOVED_FEATURES) + .find(|t| t.name == feature); + + match found { + Some(found) => found.issue, + None => panic!("feature `{feature}` is not declared anywhere"), } } -- cgit 1.4.1-3-g733a5 From 8ba91378401f5483b1d834be33911028507a9d5d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 5 Oct 2023 11:38:43 +1100 Subject: Merge `STABLE_REMOVED_FEATURES` list into `REMOVED_FEATURES`. There is a single features (`no_stack_check`) in `STABLE_REMOVED_FEATURES`. But the treatment of `STABLE_REMOVED_FEATURES` and `REMOVED_FEATURES` is actually identical. So this commit just merges them, and uses a comment to record `no_stack_check`'s unique "stable removed" status. This also lets `State::Stabilized` (which was a terrible name) be removed. --- compiler/rustc_expand/src/config.rs | 12 +++--------- compiler/rustc_feature/src/lib.rs | 5 +---- compiler/rustc_feature/src/removed.rs | 27 +++++---------------------- 3 files changed, 9 insertions(+), 35 deletions(-) (limited to 'compiler/rustc_feature/src/lib.rs') diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index e3d0af80c6a..d3f792601b7 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -15,9 +15,7 @@ use rustc_attr as attr; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::fx::FxHashMap; use rustc_feature::{Feature, Features, State as FeatureState}; -use rustc_feature::{ - ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES, -}; +use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES}; use rustc_parse::validate_attr; use rustc_session::parse::feature_err; use rustc_session::Session; @@ -154,12 +152,8 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features { } // If the declared feature is removed, issue an error. - let removed = REMOVED_FEATURES.iter().find(|f| name == f.name); - let stable_removed = STABLE_REMOVED_FEATURES.iter().find(|f| name == f.name); - if let Some(Feature { state, .. }) = removed.or(stable_removed) { - if let FeatureState::Removed { reason } | FeatureState::Stabilized { reason } = - state - { + if let Some(Feature { state, .. }) = REMOVED_FEATURES.iter().find(|f| name == f.name) { + if let FeatureState::Removed { reason } = state { sess.emit_err(FeatureRemoved { span: mi.span(), reason: reason.map(|reason| FeatureRemovedReason { reason }), diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index d4dc5920bec..4721bff0ec7 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -32,7 +32,6 @@ pub enum State { Accepted, Active { set: fn(&mut Features) }, Removed { reason: Option<&'static str> }, - Stabilized { reason: Option<&'static str> }, } impl fmt::Debug for State { @@ -41,7 +40,6 @@ impl fmt::Debug for State { State::Accepted { .. } => write!(f, "accepted"), State::Active { .. } => write!(f, "active"), State::Removed { .. } => write!(f, "removed"), - State::Stabilized { .. } => write!(f, "stabilized"), } } } @@ -113,7 +111,6 @@ fn find_lang_feature_issue(feature: Symbol) -> Option { .chain(ACTIVE_FEATURES) .chain(ACCEPTED_FEATURES) .chain(REMOVED_FEATURES) - .chain(STABLE_REMOVED_FEATURES) .find(|t| t.name == feature); match found { @@ -151,4 +148,4 @@ pub use builtin_attrs::{ is_valid_for_get_attr, AttributeGate, AttributeTemplate, AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP, }; -pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; +pub use removed::REMOVED_FEATURES; diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index da18cb2a239..de15deef178 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -20,23 +20,6 @@ macro_rules! declare_features { ),+ ]; }; - - ($( - $(#[doc = $doc:tt])* (stable_removed, $feature:ident, $ver:expr, $issue:expr, None), - )+) => { - /// Represents stable features which have since been removed (it was once Accepted) - pub const STABLE_REMOVED_FEATURES: &[Feature] = &[ - $( - Feature { - state: State::Stabilized { reason: None }, - name: sym::$feature, - since: $ver, - issue: to_nonzero($issue), - edition: None, - } - ),+ - ]; - }; } #[rustfmt::skip] @@ -141,6 +124,11 @@ declare_features! ( (removed, no_coverage, "CURRENT_RUSTC_VERSION", Some(84605), None, Some("renamed to `coverage_attribute`")), /// Allows `#[no_debug]`. (removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")), + /// Note: this feature was previously recorded in a separate + /// `STABLE_REMOVED` list because it, uniquely, was once stable but was + /// then removed. But there was no utility storing it separately, so now + /// it's in this list. + (removed, no_stack_check, "1.0.0", None, None, None), /// Allows using `#[on_unimplemented(..)]` on traits. /// (Moved to `rustc_attrs`.) (removed, on_unimplemented, "1.40.0", None, None, None), @@ -208,8 +196,3 @@ declare_features! ( // feature-group-end: removed features // ------------------------------------------------------------------------- ); - -#[rustfmt::skip] -declare_features! ( - (stable_removed, no_stack_check, "1.0.0", None, None), -); -- cgit 1.4.1-3-g733a5