diff options
| author | y21 <30553356+y21@users.noreply.github.com> | 2024-10-20 22:14:02 +0200 |
|---|---|---|
| committer | y21 <30553356+y21@users.noreply.github.com> | 2024-10-20 22:14:02 +0200 |
| commit | 2f71ce665178b08b5bea3a3e8401c75e67d57e51 (patch) | |
| tree | 7a47b23a74119d7c2934020c03942686324f9982 | |
| parent | f2f0175eb2825dc83b3414178cc4dce017b46f62 (diff) | |
| download | rust-2f71ce665178b08b5bea3a3e8401c75e67d57e51.tar.gz rust-2f71ce665178b08b5bea3a3e8401c75e67d57e51.zip | |
don't lint unnamed constants in `missing_docs_in_private_items`
| -rw-r--r-- | clippy_lints/src/missing_doc.rs | 9 | ||||
| -rw-r--r-- | tests/ui/missing_doc.rs | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index ce508d85d63..cff27681c95 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -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! { @@ -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(..) diff --git a/tests/ui/missing_doc.rs b/tests/ui/missing_doc.rs index 9c936d7fa23..a8fcbefcc0e 100644 --- a/tests/ui/missing_doc.rs +++ b/tests/ui/missing_doc.rs @@ -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. |
