Skip to content

Commit d284c8a

Browse files
committed
Rename ACTIVE_FEATURES as UNSTABLE_FEATURES.
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`.
1 parent 41b6899 commit d284c8a

File tree

14 files changed

+199
-201
lines changed

14 files changed

+199
-201
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
658658

659659
for (f1, f2) in rustc_feature::INCOMPATIBLE_FEATURES
660660
.iter()
661-
.filter(|&&(f1, f2)| features.enabled(f1) && features.enabled(f2))
661+
.filter(|&&(f1, f2)| features.active(f1) && features.active(f2))
662662
{
663663
if let Some((f1_name, f1_span)) = declared_features.clone().find(|(name, _)| name == f1) {
664664
if let Some((f2_name, f2_span)) = declared_features.clone().find(|(name, _)| name == f2)

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
323323
let gate = match op.status_in_item(self.ccx) {
324324
Status::Allowed => return,
325325

326-
Status::Unstable(gate) if self.tcx.features().enabled(gate) => {
326+
Status::Unstable(gate) if self.tcx.features().active(gate) => {
327327
let unstable_in_stable = self.ccx.is_const_stable_const_fn()
328328
&& !super::rustc_allow_const_fn_unstable(self.tcx, self.def_id(), gate);
329329
if unstable_in_stable {

compiler/rustc_expand/src/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_attr as attr;
1515
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_feature::Features;
18-
use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES};
18+
use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES};
1919
use rustc_parse::validate_attr;
2020
use rustc_session::parse::feature_err;
2121
use rustc_session::Session;
@@ -73,7 +73,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
7373
// Enable edition-dependent features based on `features_edition`.
7474
// - E.g. enable `test_2018_feature` if `features_edition` is 2018 or higher
7575
let mut edition_enabled_features = FxHashSet::default();
76-
for f in ACTIVE_FEATURES {
76+
for f in UNSTABLE_FEATURES {
7777
if let Some(edition) = f.feature.edition && edition <= features_edition {
7878
// FIXME(Manishearth) there is currently no way to set lib features by
7979
// edition.
@@ -165,7 +165,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
165165
}
166166

167167
// If the declared feature is unstable, record it.
168-
if let Some(f) = ACTIVE_FEATURES.iter().find(|f| name == f.feature.name) {
168+
if let Some(f) = UNSTABLE_FEATURES.iter().find(|f| name == f.feature.name) {
169169
(f.set_enabled)(&mut features);
170170
features.set_declared_lang_feature(name, mi.span(), None);
171171
continue;

compiler/rustc_feature/src/accepted.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! declare_features {
77
($(
88
$(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr, None),
99
)+) => {
10-
/// Those language feature has since been Accepted (it was once Active)
10+
/// Formerly unstable features that have now been accepted (stabilized).
1111
pub const ACCEPTED_FEATURES: &[Feature] = &[
1212
$(Feature {
1313
name: sym::$feature,

compiler/rustc_feature/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#![deny(rustc::diagnostic_outside_of_impl)]
1717

1818
mod accepted;
19-
mod active;
2019
mod builtin_attrs;
2120
mod removed;
21+
mod unstable;
2222

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

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

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

123123
pub use accepted::ACCEPTED_FEATURES;
124-
pub use active::{Features, ACTIVE_FEATURES, INCOMPATIBLE_FEATURES};
125124
pub use builtin_attrs::AttributeDuplicates;
126125
pub use builtin_attrs::{
127126
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, is_builtin_only_local,
128127
is_valid_for_get_attr, AttributeGate, AttributeTemplate, AttributeType, BuiltinAttribute,
129128
GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
130129
};
131130
pub use removed::REMOVED_FEATURES;
131+
pub use unstable::{Features, INCOMPATIBLE_FEATURES, UNSTABLE_FEATURES};

compiler/rustc_feature/src/removed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ macro_rules! declare_features {
1212
($(
1313
$(#[doc = $doc:tt])* (removed, $feature:ident, $ver:expr, $issue:expr, None, $reason:expr),
1414
)+) => {
15-
/// Represents unstable features which have since been removed (it was once Active)
15+
/// Formerly unstable features that have now been removed.
1616
pub const REMOVED_FEATURES: &[RemovedFeature] = &[
1717
$(RemovedFeature {
1818
feature: Feature {

0 commit comments

Comments
 (0)