Skip to content

Commit 64ae15d

Browse files
committed
Auto merge of rust-lang#86849 - jyn514:rustdoc-group, r=Manishearth
Warn when `rustdoc::` group is omitted from lint names When rustdoc lints were first made a tool lint, they gave an unconditional warning when you used the original name: ``` warning: lint `broken_intra_doc_links` has been renamed to `rustdoc::broken_intra_doc_links` --> $DIR/renamed-lint-still-applies.rs:2:9 | LL | #![deny(broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::broken_intra_doc_links` | = note: `#[warn(renamed_and_removed_lints)]` on by default ``` That was reverted in rust-lang#83203 because adding `rustdoc::x` lints would cause the code to break on old versions of the compiler (due to rust-lang#66079 (comment), "fixed" in rust-lang#83216 in the sense that you can now opt-in to not breaking on nightly, which is not ideal but `register_tool` is a long way from stabilizing). Since rust-lang#80527 is now on 1.52.0 stable, we can re-enable the warning. For nightly users, they can change immediately and still have their code work on stable; for stable users, they can change their code in 12 weeks and still have it work up to 3 releases back (about 18 weeks). That seems reasonable to me. r? `@Manishearth` cc `@rust-lang/rustdoc`
2 parents 71a567f + 7a774a8 commit 64ae15d

File tree

6 files changed

+25
-32
lines changed

6 files changed

+25
-32
lines changed

compiler/rustc_lint/src/context.rs

-16
Original file line numberDiff line numberDiff line change
@@ -276,22 +276,6 @@ impl LintStore {
276276
}
277277
}
278278

279-
/// This lint should be available with either the old or the new name.
280-
///
281-
/// Using the old name will not give a warning.
282-
/// You must register a lint with the new name before calling this function.
283-
#[track_caller]
284-
pub fn register_alias(&mut self, old_name: &str, new_name: &str) {
285-
let target = match self.by_name.get(new_name) {
286-
Some(&Id(lint_id)) => lint_id,
287-
_ => bug!("cannot add alias {} for lint {} that does not exist", old_name, new_name),
288-
};
289-
match self.by_name.insert(old_name.to_string(), Id(target)) {
290-
None | Some(Ignored) => {}
291-
Some(x) => bug!("duplicate specification of lint {} (was {:?})", old_name, x),
292-
}
293-
}
294-
295279
/// This lint should give no warning and have no effect.
296280
///
297281
/// This is used by rustc to avoid warning about old rustdoc lints before rustdoc registers them as tool lints.

src/librustdoc/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ crate fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
193193
);
194194
for lint in &*RUSTDOC_LINTS {
195195
let name = lint.name_lower();
196-
lint_store.register_alias(&name.replace("rustdoc::", ""), &name);
196+
lint_store.register_renamed(&name.replace("rustdoc::", ""), &name);
197197
}
198198
lint_store
199199
.register_renamed("intra_doc_link_resolution_failure", "rustdoc::broken_intra_doc_links");

src/test/rustdoc-ui/renamed-lint-still-applies.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// compile-args: --crate-type lib
22
#![deny(broken_intra_doc_links)]
3-
// FIXME: the old names for rustdoc lints should warn by default once `rustdoc::` makes it to the
4-
// stable channel.
3+
//~^ WARNING renamed to `rustdoc::broken_intra_doc_links`
54
//! [x]
65
//~^ ERROR unresolved link
76

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
warning: lint `broken_intra_doc_links` has been renamed to `rustdoc::broken_intra_doc_links`
2+
--> $DIR/renamed-lint-still-applies.rs:2:9
3+
|
4+
LL | #![deny(broken_intra_doc_links)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::broken_intra_doc_links`
6+
|
7+
= note: `#[warn(renamed_and_removed_lints)]` on by default
8+
19
warning: lint `rustdoc::non_autolinks` has been renamed to `rustdoc::bare_urls`
2-
--> $DIR/renamed-lint-still-applies.rs:8:9
10+
--> $DIR/renamed-lint-still-applies.rs:7:9
311
|
412
LL | #![deny(rustdoc::non_autolinks)]
513
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
6-
|
7-
= note: `#[warn(renamed_and_removed_lints)]` on by default
814

915
error: unresolved link to `x`
10-
--> $DIR/renamed-lint-still-applies.rs:5:6
16+
--> $DIR/renamed-lint-still-applies.rs:4:6
1117
|
1218
LL | //! [x]
1319
| ^ no item named `x` in scope
@@ -17,21 +23,20 @@ note: the lint level is defined here
1723
|
1824
LL | #![deny(broken_intra_doc_links)]
1925
| ^^^^^^^^^^^^^^^^^^^^^^
20-
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(broken_intra_doc_links)]`
2126
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
2227

2328
error: this URL is not a hyperlink
24-
--> $DIR/renamed-lint-still-applies.rs:10:5
29+
--> $DIR/renamed-lint-still-applies.rs:9:5
2530
|
2631
LL | //! http://example.com
2732
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.com>`
2833
|
2934
note: the lint level is defined here
30-
--> $DIR/renamed-lint-still-applies.rs:8:9
35+
--> $DIR/renamed-lint-still-applies.rs:7:9
3136
|
3237
LL | #![deny(rustdoc::non_autolinks)]
3338
| ^^^^^^^^^^^^^^^^^^^^^^
3439
= note: bare URLs are not automatically turned into clickable links
3540

36-
error: aborting due to 2 previous errors; 1 warning emitted
41+
error: aborting due to 2 previous errors; 2 warnings emitted
3742

src/test/rustdoc-ui/unknown-renamed-lints.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
//~^ ERROR renamed to `rustdoc::bare_urls`
1515

1616
#![deny(private_doc_tests)]
17-
// FIXME: the old names for rustdoc lints should warn by default once `rustdoc::` makes it to the
18-
// stable channel.
17+
//~^ ERROR renamed to `rustdoc::private_doc_tests`
1918

2019
#![deny(rustdoc)]
2120
//~^ ERROR removed: use `rustdoc::all` instead

src/test/rustdoc-ui/unknown-renamed-lints.stderr

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,25 @@ error: lint `rustdoc::non_autolinks` has been renamed to `rustdoc::bare_urls`
4040
LL | #![deny(rustdoc::non_autolinks)]
4141
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
4242

43+
error: lint `private_doc_tests` has been renamed to `rustdoc::private_doc_tests`
44+
--> $DIR/unknown-renamed-lints.rs:16:9
45+
|
46+
LL | #![deny(private_doc_tests)]
47+
| ^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::private_doc_tests`
48+
4349
error: lint `rustdoc` has been removed: use `rustdoc::all` instead
44-
--> $DIR/unknown-renamed-lints.rs:20:9
50+
--> $DIR/unknown-renamed-lints.rs:19:9
4551
|
4652
LL | #![deny(rustdoc)]
4753
| ^^^^^^^
4854

4955
error: unknown lint: `rustdoc::intra_doc_link_resolution_failure`
50-
--> $DIR/unknown-renamed-lints.rs:24:9
56+
--> $DIR/unknown-renamed-lints.rs:23:9
5157
|
5258
LL | #![deny(rustdoc::intra_doc_link_resolution_failure)]
5359
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5460

5561
error: Compilation failed, aborting rustdoc
5662

57-
error: aborting due to 8 previous errors
63+
error: aborting due to 9 previous errors
5864

0 commit comments

Comments
 (0)