Skip to content

Commit e54276f

Browse files
compiler-errorspietroalbini
authored andcommitted
Don't collect return-position impl traits for documentation
1 parent 7894a90 commit e54276f

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
@@ -398,12 +398,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
398398
| hir::ItemKind::Struct(..)
399399
| hir::ItemKind::Union(..)
400400
| hir::ItemKind::TyAlias(..)
401-
| hir::ItemKind::OpaqueTy(..)
401+
| hir::ItemKind::OpaqueTy(hir::OpaqueTy {
402+
origin: hir::OpaqueTyOrigin::TyAlias, ..
403+
})
402404
| hir::ItemKind::Static(..)
403405
| hir::ItemKind::Trait(..)
404406
| hir::ItemKind::TraitAlias(..) => {
405407
self.add_to_current_mod(item, renamed, import_id);
406408
}
409+
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
410+
origin: hir::OpaqueTyOrigin::AsyncFn(_) | hir::OpaqueTyOrigin::FnReturn(_),
411+
..
412+
}) => {
413+
// return-position impl traits are never nameable, and should never be documented.
414+
}
407415
hir::ItemKind::Const(..) => {
408416
// Underscore constants do not correspond to a nameable item and
409417
// 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)