Skip to content

Commit 91d7c57

Browse files
authored
Rework missing_docs_in_private_items (#14741)
This is blocking #14724 as it triggers the debug assertions it adds. The inter item span parsing was introduced to solve #12197. This is better handled by just not linting anything within bodies. changelog: [`missing_docs_in_private_items`]: Don't lint items in bodies and automatically derived impls changelog: [`missing_docs_in_private_items`]: Better detect when things are accessible from the crate root changelog: [`missing_docs_in_private_items`]: Lint unnameable items which are accessible outside the crate
2 parents abc17b3 + 60050e5 commit 91d7c57

20 files changed

+3237
-833
lines changed

clippy_lints/src/missing_doc.rs

Lines changed: 214 additions & 203 deletions
Large diffs are not rendered by default.

clippy_utils/src/check_proc_macro.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,14 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
265265
ItemKind::Trait(_, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
266266
ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")),
267267
ItemKind::Impl(_) => (Pat::Str("impl"), Pat::Str("}")),
268-
_ => return (Pat::Str(""), Pat::Str("")),
268+
ItemKind::Mod(..) => (Pat::Str("mod"), Pat::Str("")),
269+
ItemKind::Macro(_, def, _) => (
270+
Pat::Str(if def.macro_rules { "macro_rules" } else { "macro" }),
271+
Pat::Str(""),
272+
),
273+
ItemKind::TraitAlias(..) => (Pat::Str("trait"), Pat::Str(";")),
274+
ItemKind::GlobalAsm { .. } => return (Pat::Str("global_asm"), Pat::Str("")),
275+
ItemKind::Use(..) => return (Pat::Str(""), Pat::Str("")),
269276
};
270277
if item.vis_span.is_empty() {
271278
(start_pat, end_pat)

tests/ui-toml/missing_docs_allow_unused/missing_docs_allow_unused.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/ui-toml/missing_docs_allow_unused/missing_docs_allow_unused.stderr

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/ui-toml/missing_docs_in_private_items/default/clippy.toml

Whitespace-only changes.

0 commit comments

Comments
 (0)