Warn about unknown or renamed lints
Originally I tried to do a much broader refactoring that got rid of `init_lints` altogether. My reasoning is that now the lints aren't being run anymore (after https://github.com/rust-lang/rust/pull/73566), there's no need to ignore them explicitly. But it seems there are still some lints that aren't affected by setting `lint_mod` to a no-op: ``` deny(pub_use_of_private_extern_crate) deny(const_err) warn(unused_imports) ``` (there are possibly more, these are just the ones that failed in the rustdoc test suite). Some of these seem like we really should be warning about, but that's a much larger change and I don't propose to make it here. So for the time being, this just adds the `unknown_lints` and `renamed_or_removed_lints` passes to the list of lints rustdoc warns about.
This commit is contained in:
parent
bc7bce463f
commit
ae93bc5960
3 changed files with 45 additions and 2 deletions
|
|
@ -234,7 +234,7 @@ pub fn new_handler(
|
|||
/// It returns a tuple containing:
|
||||
/// * Vector of tuples of lints' name and their associated "max" level
|
||||
/// * HashMap of lint id with their associated "max" level
|
||||
pub fn init_lints<F>(
|
||||
pub(crate) fn init_lints<F>(
|
||||
mut allowed_lints: Vec<String>,
|
||||
lint_opts: Vec<(String, lint::Level)>,
|
||||
filter_call: F,
|
||||
|
|
@ -257,7 +257,10 @@ where
|
|||
.filter_map(|lint| {
|
||||
// Permit feature-gated lints to avoid feature errors when trying to
|
||||
// allow all lints.
|
||||
if lint.name == warnings_lint_name || lint.feature_gate.is_some() {
|
||||
if lint.name == warnings_lint_name
|
||||
|| lint.feature_gate.is_some()
|
||||
|| allowed_lints.iter().any(|l| lint.name == l)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
filter_call(lint)
|
||||
|
|
@ -328,6 +331,8 @@ pub fn run_core(
|
|||
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;
|
||||
let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name;
|
||||
let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
let renamed_and_removed_lints = rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name;
|
||||
let unknown_lints = rustc_lint::builtin::UNKNOWN_LINTS.name;
|
||||
|
||||
// In addition to those specific lints, we also need to allow those given through
|
||||
// command line, otherwise they'll get ignored and we don't want that.
|
||||
|
|
@ -338,6 +343,8 @@ pub fn run_core(
|
|||
private_doc_tests.to_owned(),
|
||||
no_crate_level_docs.to_owned(),
|
||||
invalid_codeblock_attributes_name.to_owned(),
|
||||
renamed_and_removed_lints.to_owned(),
|
||||
unknown_lints.to_owned(),
|
||||
];
|
||||
|
||||
let (lint_opts, lint_caps) = init_lints(lints_to_show, lint_opts, |lint| {
|
||||
|
|
|
|||
8
src/test/rustdoc-ui/unknown-renamed-lints.rs
Normal file
8
src/test/rustdoc-ui/unknown-renamed-lints.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![deny(unknown_lints)]
|
||||
//~^ NOTE lint level is defined
|
||||
#![deny(renamed_and_removed_lints)]
|
||||
//~^ NOTE lint level is defined
|
||||
#![deny(x)]
|
||||
//~^ ERROR unknown lint
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
//~^ ERROR lint `intra_doc_link_resolution_failure` has been renamed
|
||||
28
src/test/rustdoc-ui/unknown-renamed-lints.stderr
Normal file
28
src/test/rustdoc-ui/unknown-renamed-lints.stderr
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
error: unknown lint: `x`
|
||||
--> $DIR/unknown-renamed-lints.rs:5:9
|
||||
|
|
||||
LL | #![deny(x)]
|
||||
| ^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unknown-renamed-lints.rs:1:9
|
||||
|
|
||||
LL | #![deny(unknown_lints)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: lint `intra_doc_link_resolution_failure` has been renamed to `broken_intra_doc_links`
|
||||
--> $DIR/unknown-renamed-lints.rs:7:9
|
||||
|
|
||||
LL | #![deny(intra_doc_link_resolution_failure)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `broken_intra_doc_links`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unknown-renamed-lints.rs:3:9
|
||||
|
|
||||
LL | #![deny(renamed_and_removed_lints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: Compilation failed, aborting rustdoc
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue