1
Fork 0

Reduce clean::Type size by replacing a DefId (only used to check for display) with a boolean

This commit is contained in:
Guillaume Gomez 2022-04-12 15:06:31 +02:00
parent e1ec3260d7
commit 4054c0f3e6
3 changed files with 31 additions and 18 deletions

View file

@ -982,11 +982,7 @@ fn fmt_type<'cx>(
write!(f, "impl {}", print_generic_bounds(bounds, cx))
}
}
clean::QPath { ref assoc, ref self_type, ref trait_, ref self_def_id } => {
let should_show_cast = !trait_.segments.is_empty()
&& self_def_id
.zip(Some(trait_.def_id()))
.map_or(!self_type.is_self_type(), |(id, trait_)| id != trait_);
clean::QPath { ref assoc, ref self_type, ref trait_, should_show_cast } => {
if f.alternate() {
if should_show_cast {
write!(f, "<{:#} as {:#}>::", self_type.print(cx), trait_.print(cx))?