Skip to content

Commit

Permalink
rustdoc: reduce the amount of asyncness query executions
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed Sep 29, 2023
1 parent 854cdff commit 841bff2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,13 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
// but shouldn't change any code meaning.
let mut output = clean_middle_ty(sig.output(), cx, None, None);

if let Some(did) = did && cx.tcx.asyncness(did).is_async() {
// If the return type isn't an `impl Trait`, we can safely assume that this
// function isn't async without needing to execute the query `asyncness` at
// all which gives us a noticeable performance boost.
if let Some(did) = did
&& let Type::ImplTrait(_) = output
&& cx.tcx.asyncness(did).is_async()
{
output = output.sugared_async_return_type();
}

Expand Down

0 comments on commit 841bff2

Please sign in to comment.