Skip to content

Commit 72ef85d

Browse files
Don't collect return-position impl traits for documentation
1 parent 7c96e40 commit 72ef85d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/librustdoc/visit_ast.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
421421
| hir::ItemKind::Struct(..)
422422
| hir::ItemKind::Union(..)
423423
| hir::ItemKind::TyAlias(..)
424-
| hir::ItemKind::OpaqueTy(..)
424+
| hir::ItemKind::OpaqueTy(hir::OpaqueTy {
425+
origin: hir::OpaqueTyOrigin::TyAlias, ..
426+
})
425427
| hir::ItemKind::Static(..)
426428
| hir::ItemKind::Trait(..)
427429
| hir::ItemKind::TraitAlias(..) => {
428430
self.add_to_current_mod(item, renamed, import_id);
429431
}
432+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
433+
origin: hir::OpaqueTyOrigin::AsyncFn(_) | hir::OpaqueTyOrigin::FnReturn(_),
434+
..
435+
}) => {
436+
// return-position impl traits are never nameable, and should never be documented.
437+
}
430438
hir::ItemKind::Const(..) => {
431439
// Underscore constants do not correspond to a nameable item and
432440
// so are never useful in documentation.

tests/rustdoc/async-fn-opaque-item.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// compile-flags: --document-private-items --crate-type=lib
2+
// edition: 2021
3+
4+
// Issue 109931 -- test against accidentally documenting the `impl Future`
5+
// that comes from an async fn desugaring.
6+
7+
// Check that we don't document an unnamed opaque type
8+
// @!has async_fn_opaque_item/opaque..html
9+
10+
// Checking there is only a "Functions" header and no "Opaque types".
11+
// @has async_fn_opaque_item/index.html
12+
// @count - '//*[@class="small-section-header"]' 1
13+
// @has - '//*[@class="small-section-header"]' 'Functions'
14+
15+
pub async fn test() {}

0 commit comments

Comments
 (0)