Skip to content

Commit 3e4c778

Browse files
authored
Rollup merge of rust-lang#64471 - Mark-Simulacrum:warn-depr-attr, r=Centril
Warn on no_start, crate_id attribute use These attributes are now deprecated; they don't have any use anymore. `no_start` stopped being applicable in 3ee916e as part of rust-lang#18967. Ideally we would've removed it pre-1.0, but since that didn't happen let's at least mark it deprecated. `crate_id` was renamed to `crate_name` in 50ee1ec as part of rust-lang#15319. Ideally we would've followed that up with a removal of crate_id itself as well, but that didn't happen; this PR finally marks it as deprecated at least. Fixes rust-lang#43142 and resolves rust-lang#43144.
2 parents 1779893 + a0e48b6 commit 3e4c778

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

src/librustc_lint/builtin.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,22 @@ impl DeprecatedAttr {
669669
}
670670
}
671671

672+
fn lint_deprecated_attr(
673+
cx: &EarlyContext<'_>,
674+
attr: &ast::Attribute,
675+
msg: &str,
676+
suggestion: Option<&str>,
677+
) {
678+
cx.struct_span_lint(DEPRECATED, attr.span, &msg)
679+
.span_suggestion_short(
680+
attr.span,
681+
suggestion.unwrap_or("remove this attribute"),
682+
String::new(),
683+
Applicability::MachineApplicable
684+
)
685+
.emit();
686+
}
687+
672688
impl EarlyLintPass for DeprecatedAttr {
673689
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
674690
for &&(n, _, _, ref g) in &self.depr_attrs {
@@ -679,18 +695,15 @@ impl EarlyLintPass for DeprecatedAttr {
679695
_) = g {
680696
let msg = format!("use of deprecated attribute `{}`: {}. See {}",
681697
name, reason, link);
682-
let mut err = cx.struct_span_lint(DEPRECATED, attr.span, &msg);
683-
err.span_suggestion_short(
684-
attr.span,
685-
suggestion.unwrap_or("remove this attribute"),
686-
String::new(),
687-
Applicability::MachineApplicable
688-
);
689-
err.emit();
698+
lint_deprecated_attr(cx, attr, &msg, suggestion);
690699
}
691700
return;
692701
}
693702
}
703+
if attr.check_name(sym::no_start) || attr.check_name(sym::crate_id) {
704+
let msg = format!("use of deprecated attribute `{}`: no longer used.", attr.path);
705+
lint_deprecated_attr(cx, attr, &msg, None);
706+
}
694707
}
695708
}
696709

src/test/ui/attributes/item-attributes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#![rustc_dummy]
1212
#![rustc_dummy(attr5)]
1313

14-
#![crate_id="foobar#0.1"]
15-
1614
// These are attributes of the following mod
1715
#[rustc_dummy = "val"]
1816
#[rustc_dummy = "val"]

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@
8484
#![crate_name = "0900"]
8585
#![crate_type = "bin"] // cannot pass "0800" here
8686

87-
// For #![crate_id], see issue #43142. (I cannot bear to enshrine current behavior in a test)
87+
#![crate_id = "10"] //~ WARN use of deprecated attribute
8888

8989
// FIXME(#44232) we should warn that this isn't used.
9090
#![feature(rust1)]
9191

92-
// For #![no_start], see issue #43144. (I cannot bear to enshrine current behavior in a test)
92+
#![no_start] //~ WARN use of deprecated attribute
9393

9494
// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
9595
#![no_builtins]

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,20 @@ LL | mod inner { #![macro_escape] }
186186
|
187187
= help: consider an outer attribute, `#[macro_use]` mod ...
188188

189+
warning: use of deprecated attribute `crate_id`: no longer used.
190+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:87:1
191+
|
192+
LL | #![crate_id = "10"]
193+
| ^^^^^^^^^^^^^^^^^^^ help: remove this attribute
194+
|
195+
= note: `#[warn(deprecated)]` on by default
196+
197+
warning: use of deprecated attribute `no_start`: no longer used.
198+
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:92:1
199+
|
200+
LL | #![no_start]
201+
| ^^^^^^^^^^^^ help: remove this attribute
202+
189203
warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable
190204
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:90:12
191205
|

src/test/ui/issues/issue-1251.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#![feature(rustc_private)]
88

9-
#![crate_id="rust_get_test_int"]
10-
119
mod rustrt {
1210
extern crate libc;
1311

src/test/ui/issues/issue-6919.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// pretty-expanded FIXME #23616
66

7-
#![crate_id="issue-6919"]
87
extern crate issue6919_3;
98

109
pub fn main() {

0 commit comments

Comments
 (0)