Skip to content

Commit

Permalink
Merge pull request #2 from Infineon/filter_test_main
Browse files Browse the repository at this point in the history
Remove automatically created "main" from test documentation
  • Loading branch information
HeikeGilg authored Jul 9, 2024
2 parents 7259832 + 799fc5d commit 2d9f036
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,16 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
hir::ItemKind::Mod(ref m) => {
self.enter_mod(item.owner_id.def_id, m, name, renamed, import_id);
}
hir::ItemKind::Fn(..)
| hir::ItemKind::ExternCrate(..)
hir::ItemKind::Fn(fn_sig, _, _) => {
// Don't show auto created function "main" that is not in the source code (empty span) when documenting tests.
if !(self.cx.cache.document_tests
&& fn_sig.span.is_empty()
&& name.as_str() == "main")
{
self.add_to_current_mod(item, renamed, import_id);
}
}
hir::ItemKind::ExternCrate(..)
| hir::ItemKind::Enum(..)
| hir::ItemKind::Struct(..)
| hir::ItemKind::Union(..)
Expand Down

0 comments on commit 2d9f036

Please sign in to comment.