Skip to content

Commit 9842670

Browse files
committed
Add lint for default lint description
- Lint for any new lints that have the default lint description from the automation
1 parent fd21bfe commit 9842670

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
10861086
LintId::of(&utils::internal_lints::LINT_WITHOUT_LINT_PASS),
10871087
LintId::of(&utils::internal_lints::OUTER_EXPN_EXPN_DATA),
10881088
LintId::of(&utils::internal_lints::PRODUCE_ICE),
1089+
LintId::of(&utils::internal_lints::DEFAULT_LINT),
10891090
]);
10901091

10911092
store.register_group(true, "clippy::all", Some("clippy"), vec![

clippy_lints/src/utils/internal_lints.rs

+33
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,29 @@ declare_clippy_lint! {
121121
"this message should not appear anywhere as we ICE before and don't emit the lint"
122122
}
123123

124+
declare_clippy_lint! {
125+
/// **What it does:** Checks for cases of an auto-generated lint without an updated description,
126+
/// ie `default lint description`.
127+
///
128+
/// **Why is this bad?** Indicates that the lint is not finished.
129+
///
130+
/// **Known problems:** None
131+
///
132+
/// **Example:**
133+
/// Bad:
134+
/// ```rust,ignore
135+
/// declare_lint! { pub COOL_LINT, nursery, "default lint description" }
136+
/// ```
137+
///
138+
/// Good:
139+
/// ```rust,ignore
140+
/// declare_lint! { pub COOL_LINT, nursery, "a great new lint" }
141+
/// ```
142+
pub DEFAULT_LINT,
143+
internal,
144+
"found 'default lint description' in a lint declaration"
145+
}
146+
124147
declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);
125148

126149
impl EarlyLintPass for ClippyLintsInternal {
@@ -345,3 +368,13 @@ fn is_trigger_fn(fn_kind: FnKind<'_>) -> bool {
345368
FnKind::Closure(..) => false,
346369
}
347370
}
371+
372+
declare_lint_pass!(DefaultLint => [DEFAULT_LINT]);
373+
374+
impl EarlyLintPass for DefaultLint {
375+
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
376+
if mac.path == sym!(declare_lint) {
377+
println!("{:?}", mac);
378+
}
379+
}
380+
}

0 commit comments

Comments
 (0)