Improve error messages
- Use `register_renamed` when rustdoc is running so the lint will still be active and use a structured suggestion - Test the behavior for rustc, not just for rustdoc (because it differs)
This commit is contained in:
parent
7195355767
commit
e8ddfda813
6 changed files with 49 additions and 9 deletions
|
@ -339,6 +339,10 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
|
|||
// FIXME: maybe we could get `register_renamed` to work for tool lints?
|
||||
store.register_removed(rustdoc_lint, &format!("use `rustdoc::{}` instead", rustdoc_lint));
|
||||
}
|
||||
store.register_removed(
|
||||
"intra_doc_link_resolution_failure",
|
||||
"use `rustdoc::broken_intra_doc_links` instead",
|
||||
);
|
||||
|
||||
store.register_removed("unknown_features", "replaced by an error");
|
||||
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
|
||||
|
|
|
@ -167,6 +167,10 @@ crate fn register_lints(_sess: &Session, lint_store: &mut LintStore) {
|
|||
None,
|
||||
RUSTDOC_LINTS.iter().map(|&lint| LintId::of(lint)).collect(),
|
||||
);
|
||||
for lint in &*RUSTDOC_LINTS {
|
||||
let name = lint.name_lower();
|
||||
lint_store.register_renamed(&name.replace("rustdoc::", ""), &name);
|
||||
}
|
||||
lint_store
|
||||
.register_renamed("intra_doc_link_resolution_failure", "rustdoc::broken_intra_doc_links");
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
#![deny(rustdoc::x)]
|
||||
//~^ ERROR unknown lint: `rustdoc::x`
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
//~^ ERROR has been renamed
|
||||
//~^ ERROR renamed to `rustdoc::broken_intra_doc_links`
|
||||
|
||||
// This would ideally say 'renamed to rustdoc::non_autolinks', but this is close enough.
|
||||
#![deny(non_autolinks)]
|
||||
//~^ ERROR has been removed: use `rustdoc::non_autolinks` instead [renamed_and_removed_lints]
|
||||
//~^ ERROR renamed to `rustdoc::non_autolinks`
|
||||
|
||||
// This doesn't give you the right code directly, but at least points you on the
|
||||
// right path.
|
||||
// Explicitly don't try to handle this case, it was never valid
|
||||
#![deny(rustdoc::intra_doc_link_resolution_failure)]
|
||||
//~^ ERROR unknown lint
|
||||
|
|
|
@ -28,14 +28,14 @@ note: the lint level is defined here
|
|||
LL | #![deny(renamed_and_removed_lints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lint `non_autolinks` has been removed: use `rustdoc::non_autolinks` instead
|
||||
--> $DIR/unknown-renamed-lints.rs:13:9
|
||||
error: lint `non_autolinks` has been renamed to `rustdoc::non_autolinks`
|
||||
--> $DIR/unknown-renamed-lints.rs:12:9
|
||||
|
|
||||
LL | #![deny(non_autolinks)]
|
||||
| ^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^ help: use the new name: `rustdoc::non_autolinks`
|
||||
|
||||
error: unknown lint: `rustdoc::intra_doc_link_resolution_failure`
|
||||
--> $DIR/unknown-renamed-lints.rs:18:9
|
||||
--> $DIR/unknown-renamed-lints.rs:16:9
|
||||
|
|
||||
LL | #![deny(rustdoc::intra_doc_link_resolution_failure)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
14
src/test/ui/lint/rustdoc-renamed.rs
Normal file
14
src/test/ui/lint/rustdoc-renamed.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
#![crate_type = "lib"]
|
||||
|
||||
#![deny(unknown_lints)]
|
||||
#![deny(renamed_and_removed_lints)]
|
||||
//~^ NOTE lint level is defined
|
||||
|
||||
// both allowed, since the compiler doesn't yet know what rustdoc lints are valid
|
||||
#![deny(rustdoc::x)]
|
||||
#![deny(rustdoc::intra_doc_link_resolution_failure)]
|
||||
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
//~^ ERROR removed: use `rustdoc::broken_intra_doc_links`
|
||||
#![deny(non_autolinks)]
|
||||
//~^ ERROR removed: use `rustdoc::non_autolinks`
|
20
src/test/ui/lint/rustdoc-renamed.stderr
Normal file
20
src/test/ui/lint/rustdoc-renamed.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error: lint `intra_doc_link_resolution_failure` has been removed: use `rustdoc::broken_intra_doc_links` instead
|
||||
--> $DIR/rustdoc-renamed.rs:11:9
|
||||
|
|
||||
LL | #![deny(intra_doc_link_resolution_failure)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/rustdoc-renamed.rs:4:9
|
||||
|
|
||||
LL | #![deny(renamed_and_removed_lints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lint `non_autolinks` has been removed: use `rustdoc::non_autolinks` instead
|
||||
--> $DIR/rustdoc-renamed.rs:13:9
|
||||
|
|
||||
LL | #![deny(non_autolinks)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Add table
Reference in a new issue