Skip to content

Commit 91a0622

Browse files
committed
move the implementation under check_def_field
1 parent c468552 commit 91a0622

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

clippy_lints/src/missing_doc.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ impl MissingDoc {
9191
article: &'static str,
9292
desc: &'static str,
9393
) {
94-
// Skip checking if the item starts with underscore and allow_unused is enabled
95-
if self.allow_unused {
96-
if let Some(name) = cx.tcx.opt_item_name(def_id.to_def_id()) {
97-
if name.as_str().starts_with('_') {
98-
return;
99-
}
100-
}
101-
}
10294
// If we're building a test harness, then warning about
10395
// documentation is probably not really relevant right now.
10496
if cx.sess().opts.test {
@@ -272,6 +264,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
272264

273265
fn check_field_def(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::FieldDef<'_>) {
274266
if !sf.is_positional() {
267+
// Skip checking if the field starts with underscore and allow_unused is enabled
268+
if self.allow_unused && sf.ident.as_str().starts_with('_') {
269+
self.prev_span = Some(sf.span);
270+
return;
271+
}
272+
275273
let attrs = cx.tcx.hir_attrs(sf.hir_id);
276274
if !is_from_proc_macro(cx, sf) {
277275
self.check_missing_docs_attrs(cx, sf.def_id, attrs, sf.span, "a", "struct field");

0 commit comments

Comments
 (0)