Skip to content

Commit

Permalink
Rename ACTIVE_FEATURES as UNSTABLE_FEATURES.
Browse files Browse the repository at this point in the history
It's a better name, and lets "active features" refer to the features
that are active in a particular program, due to being declared or
enabled by the edition.

The commit also renames `Features::enabled` as `Features::active` to
match this; I changed my mind and have decided that "active" is a little
better thatn "enabled" for this, particularly because a number of
pre-existing comments use "active" in this way.

Finally, the commit renames `Status::Stable` as `Status::Accepted`, to
match `ACCEPTED_FEATURES`.
  • Loading branch information
nnethercote committed Oct 8, 2023
1 parent 7764b66 commit 23b7a0b
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 203 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ fn check_incompatible_features(sess: &Session, features: &Features) {

for (f1, f2) in rustc_feature::INCOMPATIBLE_FEATURES
.iter()
.filter(|&&(f1, f2)| features.enabled(f1) && features.enabled(f2))
.filter(|&&(f1, f2)| features.active(f1) && features.active(f2))
{
if let Some((f1_name, f1_span)) = declared_features.clone().find(|(name, _)| name == f1) {
if let Some((f2_name, f2_span)) = declared_features.clone().find(|(name, _)| name == f2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
let gate = match op.status_in_item(self.ccx) {
Status::Allowed => return,

Status::Unstable(gate) if self.tcx.features().enabled(gate) => {
Status::Unstable(gate) if self.tcx.features().active(gate) => {
let unstable_in_stable = self.ccx.is_const_stable_const_fn()
&& !super::rustc_allow_const_fn_unstable(self.tcx, self.def_id(), gate);
if unstable_in_stable {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_attr as attr;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_data_structures::fx::FxHashSet;
use rustc_feature::Features;
use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES};
use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES};
use rustc_parse::validate_attr;
use rustc_session::parse::feature_err;
use rustc_session::Session;
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
// Enable edition-dependent features based on `features_edition`.
// - E.g. enable `test_2018_feature` if `features_edition` is 2018 or higher
let mut edition_enabled_features = FxHashSet::default();
for f in ACTIVE_FEATURES {
for f in UNSTABLE_FEATURES {
if let Some(edition) = f.feature.edition && edition <= features_edition {
// FIXME(Manishearth) there is currently no way to set lib features by
// edition.
Expand Down Expand Up @@ -161,7 +161,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
}

// If the declared feature is unstable, record it.
if let Some(f) = ACTIVE_FEATURES.iter().find(|f| name == f.feature.name) {
if let Some(f) = UNSTABLE_FEATURES.iter().find(|f| name == f.feature.name) {
(f.set_enabled)(&mut features);
features.set_declared_lang_feature(name, mi.span(), None);
continue;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! declare_features {
($(
$(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr, None),
)+) => {
/// Those language feature has since been Accepted (it was once Active)
/// Formerly unstable features that have now been accepted (stabilized).
pub const ACCEPTED_FEATURES: &[Feature] = &[
$(Feature {
name: sym::$feature,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_feature/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#![deny(rustc::diagnostic_outside_of_impl)]

mod accepted;
mod active;
mod builtin_attrs;
mod removed;
mod unstable;

#[cfg(test)]
mod tests;
Expand All @@ -44,9 +44,9 @@ pub enum Stability {

#[derive(Clone, Copy, Debug, Hash)]
pub enum UnstableFeatures {
/// Hard errors for unstable features are active, as on beta/stable channels.
/// Disallow use of unstable features, as on beta/stable channels.
Disallow,
/// Allow features to be activated, as on nightly.
/// Allow use of unstable features, as on nightly.
Allow,
/// Errors are bypassed for bootstrapping. This is required any time
/// during the build that feature-related lints are set to warn or above
Expand Down Expand Up @@ -87,7 +87,7 @@ impl UnstableFeatures {

fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
// Search in all the feature lists.
if let Some(f) = ACTIVE_FEATURES.iter().find(|f| f.feature.name == feature) {
if let Some(f) = UNSTABLE_FEATURES.iter().find(|f| f.feature.name == feature) {
return f.feature.issue;
}
if let Some(f) = ACCEPTED_FEATURES.iter().find(|f| f.name == feature) {
Expand Down Expand Up @@ -121,11 +121,11 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZeroU3
}

pub use accepted::ACCEPTED_FEATURES;
pub use active::{Features, ACTIVE_FEATURES, INCOMPATIBLE_FEATURES};
pub use builtin_attrs::AttributeDuplicates;
pub use builtin_attrs::{
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, is_builtin_only_local,
is_valid_for_get_attr, AttributeGate, AttributeTemplate, AttributeType, BuiltinAttribute,
GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
};
pub use removed::REMOVED_FEATURES;
pub use unstable::{Features, INCOMPATIBLE_FEATURES, UNSTABLE_FEATURES};
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ macro_rules! declare_features {
($(
$(#[doc = $doc:tt])* (removed, $feature:ident, $ver:expr, $issue:expr, None, $reason:expr),
)+) => {
/// Represents unstable features which have since been removed (it was once Active)
/// Formerly unstable features that have now been removed.
pub const REMOVED_FEATURES: &[RemovedFeature] = &[
$(RemovedFeature {
feature: Feature {
Expand Down
Loading

0 comments on commit 23b7a0b

Please sign in to comment.