diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index aceaa2e5ab9a..73a21789c5d2 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_span::edition::Edition; use rustc_span::{Symbol, sym}; -use crate::{Features, Stability}; +use crate::Features; type GateFn = fn(&Features) -> bool; @@ -98,7 +98,6 @@ pub enum AttributeSafety { pub enum AttributeGate { /// A gated attribute which requires a feature gate to be enabled. Gated { - stability: Stability, /// The feature gate, for example `#![feature(rustc_attrs)]` for rustc_* attributes. feature: Symbol, /// The error message displayed when an attempt is made to use the attribute without its feature gate. @@ -112,12 +111,6 @@ pub enum AttributeGate { Ungated, } -impl AttributeGate { - fn is_deprecated(&self) -> bool { - matches!(*self, Self::Gated { stability: Stability::Deprecated(_, _), .. }) - } -} - /// A template that the attribute input must match. /// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now. #[derive(Clone, Copy, Default)] @@ -252,7 +245,6 @@ macro_rules! gated { template: $tpl, duplicates: $duplicates, gate: Gated { - stability: Stability::Unstable, feature: sym::$gate, message: $message, check: Features::$gate, @@ -269,7 +261,6 @@ macro_rules! gated { template: $tpl, duplicates: $duplicates, gate: Gated { - stability: Stability::Unstable, feature: sym::$attr, message: $message, check: Features::$attr, @@ -286,7 +277,6 @@ macro_rules! gated { template: $tpl, duplicates: $duplicates, gate: Gated { - stability: Stability::Unstable, feature: sym::$gate, message: $message, check: Features::$gate, @@ -303,7 +293,6 @@ macro_rules! gated { template: $tpl, duplicates: $duplicates, gate: Gated { - stability: Stability::Unstable, feature: sym::$attr, message: $message, check: Features::$attr, @@ -337,7 +326,6 @@ macro_rules! rustc_attr { template: $tpl, duplicates: $duplicates, gate: Gated { - stability: Stability::Unstable, feature: sym::rustc_attrs, message: "use of an internal attribute", check: Features::rustc_attrs, @@ -1025,7 +1013,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template: template!(NameValueStr: "name"), duplicates: ErrorFollowing, gate: Gated{ - stability: Stability::Unstable, feature: sym::rustc_attrs, message: "use of an internal attribute", check: Features::rustc_attrs, @@ -1240,10 +1227,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), ]; -pub fn deprecated_attributes() -> Vec<&'static BuiltinAttribute> { - BUILTIN_ATTRIBUTES.iter().filter(|attr| attr.gate.is_deprecated()).collect() -} - pub fn is_builtin_attr_name(name: Symbol) -> bool { BUILTIN_ATTRIBUTE_MAP.get(&name).is_some() } diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index 25764755a8fc..dbc0daa3d838 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -40,14 +40,6 @@ pub struct Feature { issue: Option>, } -#[derive(Copy, Clone, Debug)] -pub enum Stability { - Unstable, - // First argument is tracking issue link; second argument is an optional - // help message, which defaults to "remove this attribute". - Deprecated(&'static str, Option<&'static str>), -} - #[derive(Clone, Copy, Debug, Hash)] pub enum UnstableFeatures { /// Disallow use of unstable features, as on beta/stable channels. @@ -144,9 +136,8 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option, -} - -impl_lint_pass!(DeprecatedAttr => []); - -impl Default for DeprecatedAttr { - fn default() -> Self { - DeprecatedAttr { depr_attrs: deprecated_attributes() } - } -} - -impl EarlyLintPass for DeprecatedAttr { - fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) { - for BuiltinAttribute { name, gate, .. } in &self.depr_attrs { - if attr.ident().map(|ident| ident.name) == Some(*name) { - if let &AttributeGate::Gated { - stability: Stability::Deprecated(link, suggestion), - message, - .. - } = gate - { - let suggestion = match suggestion { - Some(suggestion) => { - BuiltinDeprecatedAttrLinkSuggestion::Msg { span: attr.span, suggestion } - } - None => BuiltinDeprecatedAttrLinkSuggestion::Default { span: attr.span }, - }; - cx.emit_span_lint( - DEPRECATED, - attr.span, - BuiltinDeprecatedAttrLink { name: *name, message, link, suggestion }, - ); - } - return; - } - } - } -} - fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &[ast::Attribute]) { use rustc_ast::token::CommentKind; diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 0a52e42e4428..63c884f1ab9a 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -172,7 +172,6 @@ early_lint_methods!( AnonymousParameters: AnonymousParameters, EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(), NonCamelCaseTypes: NonCamelCaseTypes, - DeprecatedAttr: DeprecatedAttr::default(), WhileTrue: WhileTrue, NonAsciiIdents: NonAsciiIdents, IncompleteInternalFeatures: IncompleteInternalFeatures, diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 82b88ec72151..0a47393eb999 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -199,32 +199,6 @@ pub(crate) struct BuiltinAnonymousParams<'a> { pub ty_snip: &'a str, } -// FIXME(davidtwco) translatable deprecated attr -#[derive(LintDiagnostic)] -#[diag(lint_builtin_deprecated_attr_link)] -pub(crate) struct BuiltinDeprecatedAttrLink<'a> { - pub name: Symbol, - pub message: &'a str, - pub link: &'a str, - #[subdiagnostic] - pub suggestion: BuiltinDeprecatedAttrLinkSuggestion<'a>, -} - -#[derive(Subdiagnostic)] -pub(crate) enum BuiltinDeprecatedAttrLinkSuggestion<'a> { - #[suggestion(lint_msg_suggestion, code = "", applicability = "machine-applicable")] - Msg { - #[primary_span] - span: Span, - suggestion: &'a str, - }, - #[suggestion(lint_default_suggestion, code = "", applicability = "machine-applicable")] - Default { - #[primary_span] - span: Span, - }, -} - #[derive(LintDiagnostic)] #[diag(lint_builtin_unused_doc_comment)] pub(crate) struct BuiltinUnusedDocComment<'a> {