about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2021-03-28 00:25:07 -0400
committerJoshua Nelson <jyn514@gmail.com>2021-04-05 04:13:36 -0400
commitd19083d9da626080cb4617caa9be8f234a9a80fa (patch)
tree26996073e09daa2e37c75d7be9e655d3dd1f6add
parentef4e5b9ecb10480cd87bd7875e4169ca5edeb0fd (diff)
downloadrust-d19083d9da626080cb4617caa9be8f234a9a80fa.tar.gz
rust-d19083d9da626080cb4617caa9be8f234a9a80fa.zip
Fix bug where rustc_lint would not apply renamed tool lints
-rw-r--r--compiler/rustc_lint/src/levels.rs7
-rw-r--r--src/test/rustdoc-ui/renamed-lint-still-applies.rs5
-rw-r--r--src/test/rustdoc-ui/renamed-lint-still-applies.stderr22
3 files changed, 30 insertions, 4 deletions
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs
index 863023fa7b5..e0857ad1eb9 100644
--- a/compiler/rustc_lint/src/levels.rs
+++ b/compiler/rustc_lint/src/levels.rs
@@ -464,15 +464,16 @@ impl<'s> LintLevelsBuilder<'s> {
                 // we don't warn about the name change.
                 if let CheckLintNameResult::Warning(_, Some(new_name)) = lint_result {
                     // Ignore any errors or warnings that happen because the new name is inaccurate
-                    if let CheckLintNameResult::Ok(ids) =
-                        store.check_lint_name(&new_name, tool_name)
-                    {
+                    // NOTE: `new_name` already includes the tool name, so we don't have to add it again.
+                    if let CheckLintNameResult::Ok(ids) = store.check_lint_name(&new_name, None) {
                         let src =
                             LintLevelSource::Node(Symbol::intern(&new_name), li.span(), reason);
                         for &id in ids {
                             self.check_gated_lint(id, attr.span);
                             self.insert_spec(&mut specs, id, (level, src));
                         }
+                    } else {
+                        panic!("renamed lint does not exist: {}", new_name);
                     }
                 }
             }
diff --git a/src/test/rustdoc-ui/renamed-lint-still-applies.rs b/src/test/rustdoc-ui/renamed-lint-still-applies.rs
index 8c61c1ccb6a..05a32d3cc31 100644
--- a/src/test/rustdoc-ui/renamed-lint-still-applies.rs
+++ b/src/test/rustdoc-ui/renamed-lint-still-applies.rs
@@ -4,3 +4,8 @@
 // stable channel.
 //! [x]
 //~^ ERROR unresolved link
+
+#![deny(rustdoc::non_autolinks)]
+//~^ WARNING renamed to `rustdoc::bare_urls`
+//! http://example.com
+//~^ ERROR not a hyperlink
diff --git a/src/test/rustdoc-ui/renamed-lint-still-applies.stderr b/src/test/rustdoc-ui/renamed-lint-still-applies.stderr
index 8a12991558a..19c253b366b 100644
--- a/src/test/rustdoc-ui/renamed-lint-still-applies.stderr
+++ b/src/test/rustdoc-ui/renamed-lint-still-applies.stderr
@@ -1,3 +1,11 @@
+warning: lint `rustdoc::non_autolinks` has been renamed to `rustdoc::bare_urls`
+  --> $DIR/renamed-lint-still-applies.rs:8:9
+   |
+LL | #![deny(rustdoc::non_autolinks)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
+   |
+   = note: `#[warn(renamed_and_removed_lints)]` on by default
+
 error: unresolved link to `x`
   --> $DIR/renamed-lint-still-applies.rs:5:6
    |
@@ -12,5 +20,17 @@ LL | #![deny(broken_intra_doc_links)]
    = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(broken_intra_doc_links)]`
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
 
-error: aborting due to previous error
+error: this URL is not a hyperlink
+  --> $DIR/renamed-lint-still-applies.rs:10:5
+   |
+LL | //! http://example.com
+   |     ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.com>`
+   |
+note: the lint level is defined here
+  --> $DIR/renamed-lint-still-applies.rs:8:9
+   |
+LL | #![deny(rustdoc::non_autolinks)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors; 1 warning emitted