diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index aecf5c5b52dba..cf19a9eb147a8 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -669,6 +669,22 @@ impl DeprecatedAttr { } } +fn lint_deprecated_attr( + cx: &EarlyContext<'_>, + attr: &ast::Attribute, + msg: &str, + suggestion: Option<&str>, +) { + cx.struct_span_lint(DEPRECATED, attr.span, &msg) + .span_suggestion_short( + attr.span, + suggestion.unwrap_or("remove this attribute"), + String::new(), + Applicability::MachineApplicable + ) + .emit(); +} + impl EarlyLintPass for DeprecatedAttr { fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) { for &&(n, _, _, ref g) in &self.depr_attrs { @@ -679,18 +695,15 @@ impl EarlyLintPass for DeprecatedAttr { _) = g { let msg = format!("use of deprecated attribute `{}`: {}. See {}", name, reason, link); - let mut err = cx.struct_span_lint(DEPRECATED, attr.span, &msg); - err.span_suggestion_short( - attr.span, - suggestion.unwrap_or("remove this attribute"), - String::new(), - Applicability::MachineApplicable - ); - err.emit(); + lint_deprecated_attr(cx, attr, &msg, suggestion); } return; } } + if attr.check_name(sym::no_start) || attr.check_name(sym::crate_id) { + let msg = format!("use of deprecated attribute `{}`: no longer used.", attr.path); + lint_deprecated_attr(cx, attr, &msg, None); + } } } diff --git a/src/test/ui/attributes/item-attributes.rs b/src/test/ui/attributes/item-attributes.rs index c760a28ecf0ba..79cd0f5fbc358 100644 --- a/src/test/ui/attributes/item-attributes.rs +++ b/src/test/ui/attributes/item-attributes.rs @@ -11,8 +11,6 @@ #![rustc_dummy] #![rustc_dummy(attr5)] -#![crate_id="foobar#0.1"] - // These are attributes of the following mod #[rustc_dummy = "val"] #[rustc_dummy = "val"] diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs index 6d51bb3f8ada8..68ff95e420895 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs @@ -84,12 +84,12 @@ #![crate_name = "0900"] #![crate_type = "bin"] // cannot pass "0800" here -// For #![crate_id], see issue #43142. (I cannot bear to enshrine current behavior in a test) +#![crate_id = "10"] //~ WARN use of deprecated attribute // FIXME(#44232) we should warn that this isn't used. #![feature(rust1)] -// For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test) +#![no_start] //~ WARN use of deprecated attribute // (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400") #![no_builtins] diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr index 864df35a79fe3..b2a6018b5354d 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr @@ -186,6 +186,20 @@ LL | mod inner { #![macro_escape] } | = help: consider an outer attribute, `#[macro_use]` mod ... +warning: use of deprecated attribute `crate_id`: no longer used. + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:87:1 + | +LL | #![crate_id = "10"] + | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: `#[warn(deprecated)]` on by default + +warning: use of deprecated attribute `no_start`: no longer used. + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:92:1 + | +LL | #![no_start] + | ^^^^^^^^^^^^ help: remove this attribute + warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable --> $DIR/issue-43106-gating-of-builtin-attrs.rs:90:12 | diff --git a/src/test/ui/issues/issue-1251.rs b/src/test/ui/issues/issue-1251.rs index 63b5a4dd1b31a..77278ecda6ecb 100644 --- a/src/test/ui/issues/issue-1251.rs +++ b/src/test/ui/issues/issue-1251.rs @@ -6,8 +6,6 @@ #![feature(rustc_private)] -#![crate_id="rust_get_test_int"] - mod rustrt { extern crate libc; diff --git a/src/test/ui/issues/issue-6919.rs b/src/test/ui/issues/issue-6919.rs index 11aed12087313..6f1e1f97708ef 100644 --- a/src/test/ui/issues/issue-6919.rs +++ b/src/test/ui/issues/issue-6919.rs @@ -4,7 +4,6 @@ // pretty-expanded FIXME #23616 -#![crate_id="issue-6919"] extern crate issue6919_3; pub fn main() {