Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d284c8a

Browse files
committedOct 15, 2023
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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 {

‎compiler/rustc_feature/src/active.rs renamed to ‎compiler/rustc_feature/src/unstable.rs

Lines changed: 171 additions & 173 deletions
Large diffs are not rendered by default.

‎compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ declare_lint! {
22492249
}
22502250

22512251
declare_lint_pass!(
2252-
/// Check for used feature gates in `INCOMPLETE_FEATURES` in `rustc_feature/src/active.rs`.
2252+
/// Check for used feature gates in `INCOMPLETE_FEATURES` in `rustc_feature/src/unstable.rs`.
22532253
IncompleteInternalFeatures => [INCOMPLETE_FEATURES, INTERNAL_FEATURES]
22542254
);
22552255

‎compiler/rustc_lint/src/expect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn provide(providers: &mut Providers) {
1111
}
1212

1313
fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
14-
if !tcx.features().enabled(sym::lint_reasons) {
14+
if !tcx.features().active(sym::lint_reasons) {
1515
return;
1616
}
1717

‎compiler/rustc_lint/src/levels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10621062
#[track_caller]
10631063
fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) -> bool {
10641064
if let Some(feature) = lint_id.lint.feature_gate {
1065-
if !self.features.enabled(feature) {
1065+
if !self.features.active(feature) {
10661066
let lint = builtin::UNKNOWN_LINTS;
10671067
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
10681068
struct_lint_level(

‎compiler/rustc_passes/src/check_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
8686
let is_feature_allowed = |feature_gate| {
8787
// All features require that the corresponding gate be enabled,
8888
// even if the function has `#[rustc_allow_const_fn_unstable(the_gate)]`.
89-
if !tcx.features().enabled(feature_gate) {
89+
if !tcx.features().active(feature_gate) {
9090
return false;
9191
}
9292

@@ -134,7 +134,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
134134

135135
let required_gates = required_gates.unwrap_or(&[]);
136136
let missing_gates: Vec<_> =
137-
required_gates.iter().copied().filter(|&g| !features.enabled(g)).collect();
137+
required_gates.iter().copied().filter(|&g| !features.active(g)).collect();
138138

139139
match missing_gates.as_slice() {
140140
[] => {

‎compiler/rustc_session/src/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct GatedSpans {
3939

4040
impl GatedSpans {
4141
/// Feature gate the given `span` under the given `feature`
42-
/// which is same `Symbol` used in `active.rs`.
42+
/// which is same `Symbol` used in `unstable.rs`.
4343
pub fn gate(&self, feature: Symbol, span: Span) {
4444
self.spans.borrow_mut().entry(feature).or_default().push(span);
4545
}
@@ -78,7 +78,7 @@ impl SymbolGallery {
7878
}
7979

8080
/// Construct a diagnostic for a language feature error due to the given `span`.
81-
/// The `feature`'s `Symbol` is the one you used in `active.rs` and `rustc_span::symbols`.
81+
/// The `feature`'s `Symbol` is the one you used in `unstable.rs` and `rustc_span::symbols`.
8282
#[track_caller]
8383
pub fn feature_err(
8484
sess: &ParseSess,

‎compiler/rustc_target/src/spec/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn is_enabled(
182182
) -> Result<(), AbiDisabled> {
183183
let s = is_stable(name);
184184
if let Err(AbiDisabled::Unstable { feature, .. }) = s {
185-
if features.enabled(feature) || span.allows_unstable(feature) {
185+
if features.active(feature) || span.allows_unstable(feature) {
186186
return Ok(());
187187
}
188188
}

‎src/tools/tidy/src/features.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ const FEATURE_GROUP_END_PREFIX: &str = "// feature-group-end";
3030

3131
#[derive(Debug, PartialEq, Clone)]
3232
pub enum Status {
33-
Stable,
33+
Accepted,
3434
Removed,
3535
Unstable,
3636
}
3737

3838
impl fmt::Display for Status {
3939
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4040
let as_str = match *self {
41-
Status::Stable => "stable",
41+
Status::Accepted => "accepted",
4242
Status::Unstable => "unstable",
4343
Status::Removed => "removed",
4444
};
@@ -279,9 +279,9 @@ fn test_filen_gate(filen_underscore: &str, features: &mut Features) -> bool {
279279

280280
pub fn collect_lang_features(base_compiler_path: &Path, bad: &mut bool) -> Features {
281281
let mut features = Features::new();
282-
collect_lang_features_in(&mut features, base_compiler_path, "active.rs", bad);
283282
collect_lang_features_in(&mut features, base_compiler_path, "accepted.rs", bad);
284283
collect_lang_features_in(&mut features, base_compiler_path, "removed.rs", bad);
284+
collect_lang_features_in(&mut features, base_compiler_path, "unstable.rs", bad);
285285
features
286286
}
287287

@@ -336,11 +336,11 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
336336

337337
let mut parts = line.split(',');
338338
let level = match parts.next().map(|l| l.trim().trim_start_matches('(')) {
339-
Some("active") => Status::Unstable,
339+
Some("unstable") => Status::Unstable,
340340
Some("incomplete") => Status::Unstable,
341341
Some("internal") => Status::Unstable,
342342
Some("removed") => Status::Removed,
343-
Some("accepted") => Status::Stable,
343+
Some("accepted") => Status::Accepted,
344344
_ => continue,
345345
};
346346
let name = parts.next().unwrap().trim();
@@ -449,7 +449,7 @@ fn get_and_check_lib_features(
449449
Ok((name, f)) => {
450450
let mut check_features = |f: &Feature, list: &Features, display: &str| {
451451
if let Some(ref s) = list.get(name) {
452-
if f.tracking_issue != s.tracking_issue && f.level != Status::Stable {
452+
if f.tracking_issue != s.tracking_issue && f.level != Status::Accepted {
453453
tidy_error!(
454454
bad,
455455
"{}:{}: `issue` \"{}\" mismatches the {} `issue` of \"{}\"",
@@ -566,7 +566,7 @@ fn map_lib_features(
566566
let level = if line.contains("[unstable(") {
567567
Status::Unstable
568568
} else if line.contains("[stable(") {
569-
Status::Stable
569+
Status::Accepted
570570
} else {
571571
continue;
572572
};
@@ -581,7 +581,7 @@ fn map_lib_features(
581581
Some(Err(_err)) => {
582582
err!("malformed stability attribute: can't parse `since` key");
583583
}
584-
None if level == Status::Stable => {
584+
None if level == Status::Accepted => {
585585
err!("malformed stability attribute: missing the `since` key");
586586
}
587587
None => None,

0 commit comments

Comments
 (0)
Please sign in to comment.