move the implementation under check_def_field

This commit is contained in:
Quang Duong Nguyen 2025-03-24 06:13:14 -04:00 committed by Kaido Aethermai
parent c468552097
commit 91a06226a1

View file

@ -91,14 +91,6 @@ impl MissingDoc {
article: &'static str,
desc: &'static str,
) {
// Skip checking if the item starts with underscore and allow_unused is enabled
if self.allow_unused {
if let Some(name) = cx.tcx.opt_item_name(def_id.to_def_id()) {
if name.as_str().starts_with('_') {
return;
}
}
}
// If we're building a test harness, then warning about
// documentation is probably not really relevant right now.
if cx.sess().opts.test {
@ -272,6 +264,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
fn check_field_def(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::FieldDef<'_>) {
if !sf.is_positional() {
// Skip checking if the field starts with underscore and allow_unused is enabled
if self.allow_unused && sf.ident.as_str().starts_with('_') {
self.prev_span = Some(sf.span);
return;
}
let attrs = cx.tcx.hir_attrs(sf.hir_id);
if !is_from_proc_macro(cx, sf) {
self.check_missing_docs_attrs(cx, sf.def_id, attrs, sf.span, "a", "struct field");