Skip to content

Commit d19083d

Browse files
committed
Fix bug where rustc_lint would not apply renamed tool lints
1 parent ef4e5b9 commit d19083d

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

compiler/rustc_lint/src/levels.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,16 @@ impl<'s> LintLevelsBuilder<'s> {
464464
// we don't warn about the name change.
465465
if let CheckLintNameResult::Warning(_, Some(new_name)) = lint_result {
466466
// Ignore any errors or warnings that happen because the new name is inaccurate
467-
if let CheckLintNameResult::Ok(ids) =
468-
store.check_lint_name(&new_name, tool_name)
469-
{
467+
// NOTE: `new_name` already includes the tool name, so we don't have to add it again.
468+
if let CheckLintNameResult::Ok(ids) = store.check_lint_name(&new_name, None) {
470469
let src =
471470
LintLevelSource::Node(Symbol::intern(&new_name), li.span(), reason);
472471
for &id in ids {
473472
self.check_gated_lint(id, attr.span);
474473
self.insert_spec(&mut specs, id, (level, src));
475474
}
475+
} else {
476+
panic!("renamed lint does not exist: {}", new_name);
476477
}
477478
}
478479
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
// stable channel.
55
//! [x]
66
//~^ ERROR unresolved link
7+
8+
#![deny(rustdoc::non_autolinks)]
9+
//~^ WARNING renamed to `rustdoc::bare_urls`
10+
//! http://example.com
11+
//~^ ERROR not a hyperlink

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

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
warning: lint `rustdoc::non_autolinks` has been renamed to `rustdoc::bare_urls`
2+
--> $DIR/renamed-lint-still-applies.rs:8:9
3+
|
4+
LL | #![deny(rustdoc::non_autolinks)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
6+
|
7+
= note: `#[warn(renamed_and_removed_lints)]` on by default
8+
19
error: unresolved link to `x`
210
--> $DIR/renamed-lint-still-applies.rs:5:6
311
|
@@ -12,5 +20,17 @@ LL | #![deny(broken_intra_doc_links)]
1220
= note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(broken_intra_doc_links)]`
1321
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1422

15-
error: aborting due to previous error
23+
error: this URL is not a hyperlink
24+
--> $DIR/renamed-lint-still-applies.rs:10:5
25+
|
26+
LL | //! http://example.com
27+
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.com>`
28+
|
29+
note: the lint level is defined here
30+
--> $DIR/renamed-lint-still-applies.rs:8:9
31+
|
32+
LL | #![deny(rustdoc::non_autolinks)]
33+
| ^^^^^^^^^^^^^^^^^^^^^^
34+
35+
error: aborting due to 2 previous errors; 1 warning emitted
1636

0 commit comments

Comments
 (0)