Skip to content

lint-docs: Warn on missing lint when documenting. #80395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/tools/lint-docs/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,23 @@ impl<'a> LintExtractor<'a> {
result.push('\n');
result.push_str("[warn-by-default]: listing/warn-by-default.md\n");
for lint_name in to_link {
let lint_def =
lints.iter().find(|l| l.name == lint_name.replace("-", "_")).ok_or_else(|| {
format!(
"`rustc -W help` defined lint `{}` but that lint does not appear to exist",
let lint_def = match lints.iter().find(|l| l.name == lint_name.replace("-", "_")) {
Some(def) => def,
None => {
let msg = format!(
"`rustc -W help` defined lint `{}` but that lint does not \
appear to exist\n\
Check that the lint definition includes the appropriate doc comments.",
lint_name
)
})?;
);
if self.validate {
return Err(msg.into());
} else {
eprintln!("warning: {}", msg);
continue;
}
}
};
write!(
result,
"[{}]: listing/{}#{}\n",
Expand Down