Skip to content

Commit

Permalink
don't lint unnamed constants in missing_docs_in_private_items
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Oct 20, 2024
1 parent f2f0175 commit 2f71ce6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty::Visibility;
use rustc_session::impl_lint_pass;
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::symbol::kw;
use rustc_span::{Span, sym};

declare_clippy_lint! {
Expand Down Expand Up @@ -184,8 +185,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
}
}
},
hir::ItemKind::Const(..)
| hir::ItemKind::Enum(..)
hir::ItemKind::Const(..) => {
if it.ident.name == kw::Underscore {
note_prev_span_then_ret!(self.prev_span, it.span);
}
},
hir::ItemKind::Enum(..)
| hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Static(..)
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ with_span!(span pub fn foo_pm() {});
with_span!(span pub static FOO_PM: u32 = 0;);
with_span!(span pub const FOO2_PM: u32 = 0;);

// Don't lint unnamed constants
const _: () = ();

// issue #12197
// Undocumented field originated inside of spanned proc-macro attribute
/// Some dox for struct.
Expand Down

0 comments on commit 2f71ce6

Please sign in to comment.