Skip to content

Commit 2f71ce6

Browse files
committed
don't lint unnamed constants in missing_docs_in_private_items
1 parent f2f0175 commit 2f71ce6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clippy_lints/src/missing_doc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
1717
use rustc_middle::ty::Visibility;
1818
use rustc_session::impl_lint_pass;
1919
use rustc_span::def_id::CRATE_DEF_ID;
20+
use rustc_span::symbol::kw;
2021
use rustc_span::{Span, sym};
2122

2223
declare_clippy_lint! {
@@ -184,8 +185,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
184185
}
185186
}
186187
},
187-
hir::ItemKind::Const(..)
188-
| hir::ItemKind::Enum(..)
188+
hir::ItemKind::Const(..) => {
189+
if it.ident.name == kw::Underscore {
190+
note_prev_span_then_ret!(self.prev_span, it.span);
191+
}
192+
},
193+
hir::ItemKind::Enum(..)
189194
| hir::ItemKind::Macro(..)
190195
| hir::ItemKind::Mod(..)
191196
| hir::ItemKind::Static(..)

tests/ui/missing_doc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ with_span!(span pub fn foo_pm() {});
116116
with_span!(span pub static FOO_PM: u32 = 0;);
117117
with_span!(span pub const FOO2_PM: u32 = 0;);
118118

119+
// Don't lint unnamed constants
120+
const _: () = ();
121+
119122
// issue #12197
120123
// Undocumented field originated inside of spanned proc-macro attribute
121124
/// Some dox for struct.

0 commit comments

Comments
 (0)