Skip to content

Commit 1c82e5e

Browse files
committed
Convert empty tuple to DefaultReturn in ty path
1 parent 2f7b7d5 commit 1c82e5e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,15 @@ fn clean_fn_decl_from_did_and_sig(
895895
) -> FnDecl {
896896
let mut names = did.map_or(&[] as &[_], |did| cx.tcx.fn_arg_names(did)).iter();
897897

898+
// We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
899+
// but shouldn't change any code meaning.
900+
let output = match sig.skip_binder().output().clean(cx) {
901+
Type::Tuple(inner) if inner.len() == 0 => DefaultReturn,
902+
ty => Return(ty),
903+
};
904+
898905
FnDecl {
899-
output: Return(sig.skip_binder().output().clean(cx)),
906+
output,
900907
c_variadic: sig.skip_binder().c_variadic,
901908
inputs: Arguments {
902909
values: sig

0 commit comments

Comments
 (0)