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 1f2ade0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,12 @@ 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 is not an `impl Trait`, we can safely assume that this function isn't async
// without needing to execute the `asyncness` query which gives us a slight 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 1f2ade0

Please sign in to comment.