Skip to content

Commit 1f2ade0

Browse files
committed
rustdoc: reduce the amount of asyncness query executions
1 parent 854cdff commit 1f2ade0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,12 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
11831183
// but shouldn't change any code meaning.
11841184
let mut output = clean_middle_ty(sig.output(), cx, None, None);
11851185

1186-
if let Some(did) = did && cx.tcx.asyncness(did).is_async() {
1186+
// If the return type is not an `impl Trait`, we can safely assume that this function isn't async
1187+
// without needing to execute the `asyncness` query which gives us a slight performance boost.
1188+
if let Some(did) = did
1189+
&& let Type::ImplTrait(_) = output
1190+
&& cx.tcx.asyncness(did).is_async()
1191+
{
11871192
output = output.sugared_async_return_type();
11881193
}
11891194

0 commit comments

Comments
 (0)