Skip to content

Commit

Permalink
Remove auto created function main from test documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikeGilg committed Jul 8, 2024
1 parent 7259832 commit 799fc5d
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 799fc5d

Please sign in to comment.