Skip to content

Commit 841bff2

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/librustdoc/clean/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,13 @@ 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 isn't an `impl Trait`, we can safely assume that this
1187+
// function isn't async without needing to execute the query `asyncness` at
1188+
// all which gives us a noticeable performance boost.
1189+
if let Some(did) = did
1190+
&& let Type::ImplTrait(_) = output
1191+
&& cx.tcx.asyncness(did).is_async()
1192+
{
11871193
output = output.sugared_async_return_type();
11881194
}
11891195

0 commit comments

Comments
 (0)