Skip to content

Commit 81eb182

Browse files
committed
Remove rustc_feature::Stability
1 parent 959d6de commit 81eb182

File tree

6 files changed

+5
-106
lines changed

6 files changed

+5
-106
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_data_structures::fx::FxHashMap;
99
use rustc_span::edition::Edition;
1010
use rustc_span::{Symbol, sym};
1111

12-
use crate::{Features, Stability};
12+
use crate::Features;
1313

1414
type GateFn = fn(&Features) -> bool;
1515

@@ -98,7 +98,6 @@ pub enum AttributeSafety {
9898
pub enum AttributeGate {
9999
/// A gated attribute which requires a feature gate to be enabled.
100100
Gated {
101-
stability: Stability,
102101
/// The feature gate, for example `#![feature(rustc_attrs)]` for rustc_* attributes.
103102
feature: Symbol,
104103
/// The error message displayed when an attempt is made to use the attribute without its feature gate.
@@ -112,12 +111,6 @@ pub enum AttributeGate {
112111
Ungated,
113112
}
114113

115-
impl AttributeGate {
116-
fn is_deprecated(&self) -> bool {
117-
matches!(*self, Self::Gated { stability: Stability::Deprecated(_, _), .. })
118-
}
119-
}
120-
121114
/// A template that the attribute input must match.
122115
/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
123116
#[derive(Clone, Copy, Default)]
@@ -252,7 +245,6 @@ macro_rules! gated {
252245
template: $tpl,
253246
duplicates: $duplicates,
254247
gate: Gated {
255-
stability: Stability::Unstable,
256248
feature: sym::$gate,
257249
message: $message,
258250
check: Features::$gate,
@@ -269,7 +261,6 @@ macro_rules! gated {
269261
template: $tpl,
270262
duplicates: $duplicates,
271263
gate: Gated {
272-
stability: Stability::Unstable,
273264
feature: sym::$attr,
274265
message: $message,
275266
check: Features::$attr,
@@ -286,7 +277,6 @@ macro_rules! gated {
286277
template: $tpl,
287278
duplicates: $duplicates,
288279
gate: Gated {
289-
stability: Stability::Unstable,
290280
feature: sym::$gate,
291281
message: $message,
292282
check: Features::$gate,
@@ -303,7 +293,6 @@ macro_rules! gated {
303293
template: $tpl,
304294
duplicates: $duplicates,
305295
gate: Gated {
306-
stability: Stability::Unstable,
307296
feature: sym::$attr,
308297
message: $message,
309298
check: Features::$attr,
@@ -337,7 +326,6 @@ macro_rules! rustc_attr {
337326
template: $tpl,
338327
duplicates: $duplicates,
339328
gate: Gated {
340-
stability: Stability::Unstable,
341329
feature: sym::rustc_attrs,
342330
message: "use of an internal attribute",
343331
check: Features::rustc_attrs,
@@ -1025,7 +1013,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
10251013
template: template!(NameValueStr: "name"),
10261014
duplicates: ErrorFollowing,
10271015
gate: Gated{
1028-
stability: Stability::Unstable,
10291016
feature: sym::rustc_attrs,
10301017
message: "use of an internal attribute",
10311018
check: Features::rustc_attrs,
@@ -1240,10 +1227,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
12401227
),
12411228
];
12421229

1243-
pub fn deprecated_attributes() -> Vec<&'static BuiltinAttribute> {
1244-
BUILTIN_ATTRIBUTES.iter().filter(|attr| attr.gate.is_deprecated()).collect()
1245-
}
1246-
12471230
pub fn is_builtin_attr_name(name: Symbol) -> bool {
12481231
BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
12491232
}

compiler/rustc_feature/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ pub struct Feature {
4040
issue: Option<NonZero<u32>>,
4141
}
4242

43-
#[derive(Copy, Clone, Debug)]
44-
pub enum Stability {
45-
Unstable,
46-
// First argument is tracking issue link; second argument is an optional
47-
// help message, which defaults to "remove this attribute".
48-
Deprecated(&'static str, Option<&'static str>),
49-
}
50-
5143
#[derive(Clone, Copy, Debug, Hash)]
5244
pub enum UnstableFeatures {
5345
/// Disallow use of unstable features, as on beta/stable channels.
@@ -144,9 +136,8 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZero<u
144136
pub use accepted::ACCEPTED_LANG_FEATURES;
145137
pub use builtin_attrs::{
146138
AttributeDuplicates, AttributeGate, AttributeSafety, AttributeTemplate, AttributeType,
147-
BUILTIN_ATTRIBUTE_MAP, BUILTIN_ATTRIBUTES, BuiltinAttribute, GatedCfg, deprecated_attributes,
148-
encode_cross_crate, find_gated_cfg, is_builtin_attr_name, is_stable_diagnostic_attribute,
149-
is_valid_for_get_attr,
139+
BUILTIN_ATTRIBUTE_MAP, BUILTIN_ATTRIBUTES, BuiltinAttribute, GatedCfg, encode_cross_crate,
140+
find_gated_cfg, is_builtin_attr_name, is_stable_diagnostic_attribute, is_valid_for_get_attr,
150141
};
151142
pub use removed::REMOVED_LANG_FEATURES;
152143
pub use unstable::{

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ lint_builtin_const_no_mangle = const items should never be `#[no_mangle]`
7272
lint_builtin_decl_unsafe_fn = declaration of an `unsafe` function
7373
lint_builtin_decl_unsafe_method = declaration of an `unsafe` method
7474
75-
lint_builtin_deprecated_attr_link = use of deprecated attribute `{$name}`: {$message}. See {$link}
76-
.msg_suggestion = {$suggestion}
77-
.default_suggestion = remove this attribute
7875
lint_builtin_deref_nullptr = dereferencing a null pointer
7976
.label = this code causes undefined behavior when executed
8077

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_ast::visit::{FnCtxt, FnKind};
2222
use rustc_ast::{self as ast, *};
2323
use rustc_ast_pretty::pprust::expr_to_string;
2424
use rustc_errors::{Applicability, LintDiagnostic};
25-
use rustc_feature::{AttributeGate, BuiltinAttribute, GateIssue, Stability, deprecated_attributes};
25+
use rustc_feature::GateIssue;
2626
use rustc_hir as hir;
2727
use rustc_hir::def::{DefKind, Res};
2828
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
@@ -48,8 +48,7 @@ use rustc_trait_selection::traits::{self};
4848

4949
use crate::errors::BuiltinEllipsisInclusiveRangePatterns;
5050
use crate::lints::{
51-
BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDeprecatedAttrLink,
52-
BuiltinDeprecatedAttrLinkSuggestion, BuiltinDerefNullptr, BuiltinDoubleNegations,
51+
BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDerefNullptr, BuiltinDoubleNegations,
5352
BuiltinDoubleNegationsAddParens, BuiltinEllipsisInclusiveRangePatternsLint,
5453
BuiltinExplicitOutlives, BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote,
5554
BuiltinIncompleteFeatures, BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures,
@@ -798,50 +797,6 @@ impl EarlyLintPass for AnonymousParameters {
798797
}
799798
}
800799

801-
/// Check for use of attributes which have been deprecated.
802-
#[derive(Clone)]
803-
pub struct DeprecatedAttr {
804-
// This is not free to compute, so we want to keep it around, rather than
805-
// compute it for every attribute.
806-
depr_attrs: Vec<&'static BuiltinAttribute>,
807-
}
808-
809-
impl_lint_pass!(DeprecatedAttr => []);
810-
811-
impl Default for DeprecatedAttr {
812-
fn default() -> Self {
813-
DeprecatedAttr { depr_attrs: deprecated_attributes() }
814-
}
815-
}
816-
817-
impl EarlyLintPass for DeprecatedAttr {
818-
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
819-
for BuiltinAttribute { name, gate, .. } in &self.depr_attrs {
820-
if attr.ident().map(|ident| ident.name) == Some(*name) {
821-
if let &AttributeGate::Gated {
822-
stability: Stability::Deprecated(link, suggestion),
823-
message,
824-
..
825-
} = gate
826-
{
827-
let suggestion = match suggestion {
828-
Some(suggestion) => {
829-
BuiltinDeprecatedAttrLinkSuggestion::Msg { span: attr.span, suggestion }
830-
}
831-
None => BuiltinDeprecatedAttrLinkSuggestion::Default { span: attr.span },
832-
};
833-
cx.emit_span_lint(
834-
DEPRECATED,
835-
attr.span,
836-
BuiltinDeprecatedAttrLink { name: *name, message, link, suggestion },
837-
);
838-
}
839-
return;
840-
}
841-
}
842-
}
843-
}
844-
845800
fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &[ast::Attribute]) {
846801
use rustc_ast::token::CommentKind;
847802

compiler/rustc_lint/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ early_lint_methods!(
172172
AnonymousParameters: AnonymousParameters,
173173
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(),
174174
NonCamelCaseTypes: NonCamelCaseTypes,
175-
DeprecatedAttr: DeprecatedAttr::default(),
176175
WhileTrue: WhileTrue,
177176
NonAsciiIdents: NonAsciiIdents,
178177
IncompleteInternalFeatures: IncompleteInternalFeatures,

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,32 +199,6 @@ pub(crate) struct BuiltinAnonymousParams<'a> {
199199
pub ty_snip: &'a str,
200200
}
201201

202-
// FIXME(davidtwco) translatable deprecated attr
203-
#[derive(LintDiagnostic)]
204-
#[diag(lint_builtin_deprecated_attr_link)]
205-
pub(crate) struct BuiltinDeprecatedAttrLink<'a> {
206-
pub name: Symbol,
207-
pub message: &'a str,
208-
pub link: &'a str,
209-
#[subdiagnostic]
210-
pub suggestion: BuiltinDeprecatedAttrLinkSuggestion<'a>,
211-
}
212-
213-
#[derive(Subdiagnostic)]
214-
pub(crate) enum BuiltinDeprecatedAttrLinkSuggestion<'a> {
215-
#[suggestion(lint_msg_suggestion, code = "", applicability = "machine-applicable")]
216-
Msg {
217-
#[primary_span]
218-
span: Span,
219-
suggestion: &'a str,
220-
},
221-
#[suggestion(lint_default_suggestion, code = "", applicability = "machine-applicable")]
222-
Default {
223-
#[primary_span]
224-
span: Span,
225-
},
226-
}
227-
228202
#[derive(LintDiagnostic)]
229203
#[diag(lint_builtin_unused_doc_comment)]
230204
pub(crate) struct BuiltinUnusedDocComment<'a> {

0 commit comments

Comments
 (0)