Skip to content

Commit e974fe4

Browse files
committed
Remove edition umbrella features.
1 parent 0e7f91b commit e974fe4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+468
-662
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ E0700: include_str!("./error_codes/E0700.md"),
429429
E0701: include_str!("./error_codes/E0701.md"),
430430
E0703: include_str!("./error_codes/E0703.md"),
431431
E0704: include_str!("./error_codes/E0704.md"),
432-
E0705: include_str!("./error_codes/E0705.md"),
433432
E0706: include_str!("./error_codes/E0706.md"),
434433
E0708: include_str!("./error_codes/E0708.md"),
435434
E0710: include_str!("./error_codes/E0710.md"),
@@ -648,6 +647,7 @@ E0795: include_str!("./error_codes/E0795.md"),
648647
// E0645, // trait aliases not finished
649648
// E0694, // an unknown tool name found in scoped attributes
650649
// E0702, // replaced with a generic attribute input check
650+
// E0705, // removed
651651
// E0707, // multiple elided lifetimes used in arguments of `async fn`
652652
// E0709, // multiple different lifetimes used in arguments of `async fn`
653653
// E0721, // `await` keyword

compiler/rustc_error_codes/src/error_codes/E0705.md

-11
This file was deleted.

compiler/rustc_expand/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ expand_explain_doc_comment_outer =
3535
expand_expr_repeat_no_syntax_vars =
3636
attempted to repeat an expression containing no syntax variables matched as repeating at this depth
3737
38-
expand_feature_included_in_edition =
39-
the feature `{$feature}` is included in the Rust {$edition} edition
40-
4138
expand_feature_not_allowed =
4239
the feature `{$name}` is not in the list of allowed features
4340

compiler/rustc_expand/src/config.rs

+2-72
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Conditional compilation stripping.
22
33
use crate::errors::{
4-
FeatureIncludedInEdition, FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg,
5-
MalformedFeatureAttribute, MalformedFeatureAttributeHelp, RemoveExprNotSupported,
4+
FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute,
5+
MalformedFeatureAttributeHelp, RemoveExprNotSupported,
66
};
77
use rustc_ast::ptr::P;
88
use rustc_ast::token::{Delimiter, Token, TokenKind};
@@ -13,13 +13,11 @@ use rustc_ast::NodeId;
1313
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
1414
use rustc_attr as attr;
1515
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
16-
use rustc_data_structures::fx::FxHashSet;
1716
use rustc_feature::Features;
1817
use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES};
1918
use rustc_parse::validate_attr;
2019
use rustc_session::parse::feature_err;
2120
use rustc_session::Session;
22-
use rustc_span::edition::ALL_EDITIONS;
2321
use rustc_span::symbol::{sym, Symbol};
2422
use rustc_span::Span;
2523
use thin_vec::ThinVec;
@@ -48,42 +46,6 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
4846

4947
let mut features = Features::default();
5048

51-
// The edition from `--edition`.
52-
let crate_edition = sess.edition();
53-
54-
// The maximum of (a) the edition from `--edition` and (b) any edition
55-
// umbrella feature-gates declared in the code.
56-
// - E.g. if `crate_edition` is 2015 but `rust_2018_preview` is present,
57-
// `feature_edition` is 2018
58-
let mut features_edition = crate_edition;
59-
for attr in krate_attrs {
60-
for mi in feature_list(attr) {
61-
if mi.is_word() {
62-
let name = mi.name_or_empty();
63-
let edition = ALL_EDITIONS.iter().find(|e| name == e.feature_name()).copied();
64-
if let Some(edition) = edition
65-
&& edition > features_edition
66-
{
67-
features_edition = edition;
68-
}
69-
}
70-
}
71-
}
72-
73-
// Enable edition-dependent features based on `features_edition`.
74-
// - E.g. enable `test_2018_feature` if `features_edition` is 2018 or higher
75-
let mut edition_enabled_features = FxHashSet::default();
76-
for f in UNSTABLE_FEATURES {
77-
if let Some(edition) = f.feature.edition
78-
&& edition <= features_edition
79-
{
80-
// FIXME(Manishearth) there is currently no way to set lib features by
81-
// edition.
82-
edition_enabled_features.insert(f.feature.name);
83-
(f.set_enabled)(&mut features);
84-
}
85-
}
86-
8749
// Process all features declared in the code.
8850
for attr in krate_attrs {
8951
for mi in feature_list(attr) {
@@ -108,38 +70,6 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
10870
}
10971
};
11072

111-
// If the declared feature is an edition umbrella feature-gate,
112-
// warn if it was redundant w.r.t. `crate_edition`.
113-
// - E.g. warn if `rust_2018_preview` is declared when
114-
// `crate_edition` is 2018
115-
// - E.g. don't warn if `rust_2018_preview` is declared when
116-
// `crate_edition` is 2015.
117-
if let Some(&edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) {
118-
if edition <= crate_edition {
119-
sess.emit_warning(FeatureIncludedInEdition {
120-
span: mi.span(),
121-
feature: name,
122-
edition,
123-
});
124-
}
125-
features.set_declared_lang_feature(name, mi.span(), None);
126-
continue;
127-
}
128-
129-
// If the declared feature is edition-dependent and was already
130-
// enabled due to `feature_edition`, give a warning.
131-
// - E.g. warn if `test_2018_feature` is declared when
132-
// `feature_edition` is 2018 or higher.
133-
if edition_enabled_features.contains(&name) {
134-
sess.emit_warning(FeatureIncludedInEdition {
135-
span: mi.span(),
136-
feature: name,
137-
edition: features_edition,
138-
});
139-
features.set_declared_lang_feature(name, mi.span(), None);
140-
continue;
141-
}
142-
14373
// If the declared feature has been removed, issue an error.
14474
if let Some(f) = REMOVED_FEATURES.iter().find(|f| name == f.feature.name) {
14575
sess.emit_err(FeatureRemoved {

compiler/rustc_expand/src/errors.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use rustc_ast::ast;
22
use rustc_macros::Diagnostic;
33
use rustc_session::Limit;
4-
use rustc_span::edition::Edition;
54
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
65
use rustc_span::{Span, Symbol};
76
use std::borrow::Cow;
@@ -168,15 +167,6 @@ pub(crate) struct TakesNoArguments<'a> {
168167
pub name: &'a str,
169168
}
170169

171-
#[derive(Diagnostic)]
172-
#[diag(expand_feature_included_in_edition, code = "E0705")]
173-
pub(crate) struct FeatureIncludedInEdition {
174-
#[primary_span]
175-
pub span: Span,
176-
pub feature: Symbol,
177-
pub edition: Edition,
178-
}
179-
180170
#[derive(Diagnostic)]
181171
#[diag(expand_feature_removed, code = "E0557")]
182172
pub(crate) struct FeatureRemoved<'a> {

0 commit comments

Comments
 (0)