From 966621563e40f262b3e14d1ff785d97937ddf1ef Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 26 Dec 2020 13:48:09 -0800 Subject: [PATCH] lint-docs: Warn on missing lint when documenting. --- src/tools/lint-docs/src/groups.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/tools/lint-docs/src/groups.rs b/src/tools/lint-docs/src/groups.rs index 0a69b18a33254..e8fd19a63812b 100644 --- a/src/tools/lint-docs/src/groups.rs +++ b/src/tools/lint-docs/src/groups.rs @@ -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",