Skip to content

Commit 67eb8cd

Browse files
committed
Auto merge of #116195 - fmease:rustdoc-investigate-perf-regression, r=<try>
[perf] rustdoc: investigate recent perf regression Investigate perf regression caused by #116084. r? `@ghost`
2 parents a6dfd89 + d08ad3f commit 67eb8cd

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/librustdoc/clean/types.rs

+9-26
Original file line numberDiff line numberDiff line change
@@ -1604,14 +1604,16 @@ impl Type {
16041604
///
16051605
/// This function will panic if the return type does not match the expected sugaring for async
16061606
/// functions.
1607-
pub(crate) fn sugared_async_return_type(&self) -> Type {
1608-
if let Type::ImplTrait(v) = self &&
1609-
let [GenericBound::TraitBound(PolyTrait { trait_, .. }, _ )] = &v[..]
1607+
pub(crate) fn sugared_async_return_type(self) -> Type {
1608+
if let Type::ImplTrait(mut v) = self
1609+
&& let Some(GenericBound::TraitBound(PolyTrait { mut trait_, .. }, _ )) = v.pop()
1610+
&& let Some(segment) = trait_.segments.pop()
1611+
&& let GenericArgs::AngleBracketed { mut bindings, .. } = segment.args
1612+
&& let Some(binding) = bindings.pop()
1613+
&& let TypeBindingKind::Equality { term } = binding.kind
1614+
&& let Term::Type(ty) = term
16101615
{
1611-
let bindings = trait_.bindings().unwrap();
1612-
let ret_ty = bindings[0].term();
1613-
let ty = ret_ty.ty().expect("unexpected constant in async fn return term");
1614-
ty.clone()
1616+
ty
16151617
} else {
16161618
panic!("unexpected async fn return type")
16171619
}
@@ -2189,16 +2191,6 @@ impl Path {
21892191
}
21902192
})
21912193
}
2192-
2193-
pub(crate) fn bindings(&self) -> Option<&[TypeBinding]> {
2194-
self.segments.last().and_then(|seg| {
2195-
if let GenericArgs::AngleBracketed { ref bindings, .. } = seg.args {
2196-
Some(&**bindings)
2197-
} else {
2198-
None
2199-
}
2200-
})
2201-
}
22022194
}
22032195

22042196
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
@@ -2478,15 +2470,6 @@ pub(crate) enum TypeBindingKind {
24782470
Constraint { bounds: Vec<GenericBound> },
24792471
}
24802472

2481-
impl TypeBinding {
2482-
pub(crate) fn term(&self) -> &Term {
2483-
match self.kind {
2484-
TypeBindingKind::Equality { ref term } => term,
2485-
_ => panic!("expected equality type binding for parenthesized generic args"),
2486-
}
2487-
}
2488-
}
2489-
24902473
/// The type, lifetime, or constant that a private type alias's parameter should be
24912474
/// replaced with when expanding a use of that type alias.
24922475
///

0 commit comments

Comments
 (0)