Skip to content

Commit ff2c563

Browse files
committed
Auto merge of #118823 - GuillaumeGomez:rollup-6v51gxv, r=GuillaumeGomez
Rollup of 3 pull requests Successful merges: - #118802 (Remove edition umbrella features.) - #118807 (Remove an allocation in min_stack) - #118812 (rustdoc-search: do not treat associated type names as types) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6f40082 + c89672e commit ff2c563

Some content is hidden

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

54 files changed

+588
-667
lines changed

compiler/rustc_error_codes/src/error_codes/E0705.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
A `#![feature]` attribute was declared for a feature that is stable in the
24
current edition, but not in all editions.
35

46
Erroneous code example:
57

6-
```rust2018,compile_fail,E0705
8+
```compile_fail
79
#![feature(rust_2018_preview)]
810
#![feature(test_2018_feature)] // error: the feature
911
// `test_2018_feature` is

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};
@@ -12,13 +12,11 @@ use rustc_ast::NodeId;
1212
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
1313
use rustc_attr as attr;
1414
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
15-
use rustc_data_structures::fx::FxHashSet;
1615
use rustc_feature::Features;
1716
use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES};
1817
use rustc_parse::validate_attr;
1918
use rustc_session::parse::feature_err;
2019
use rustc_session::Session;
21-
use rustc_span::edition::ALL_EDITIONS;
2220
use rustc_span::symbol::{sym, Symbol};
2321
use rustc_span::Span;
2422
use thin_vec::ThinVec;
@@ -47,42 +45,6 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
4745

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

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

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