1
Fork 0

rustdoc: Refactor Impl.{synthetic,blanket_impl} into enum

This change has two advantages:

1. It makes the possible states clearer, and it makes it impossible to
   construct invalid states, such as a blanket impl that is also an auto
   trait impl.

2. It shrinks the size of `Impl` a bit, since now there is only one
   field, rather than two.
This commit is contained in:
Noah Lev 2021-11-06 23:10:01 -07:00
parent c32ee54380
commit 7b7023cb72
12 changed files with 66 additions and 36 deletions

View file

@ -1147,9 +1147,9 @@ fn render_assoc_items_inner(
}
let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) =
traits.iter().partition(|t| t.inner_impl().synthetic);
traits.iter().partition(|t| t.inner_impl().is_auto_impl());
let (blanket_impl, concrete): (Vec<&&Impl>, _) =
concrete.into_iter().partition(|t| t.inner_impl().blanket_impl.is_some());
concrete.into_iter().partition(|t| t.inner_impl().is_blanket_impl());
let mut impls = Buffer::empty_from(w);
render_impls(cx, &mut impls, &concrete, containing_item);
@ -2058,10 +2058,9 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
};
let (synthetic, concrete): (Vec<&Impl>, Vec<&Impl>) =
v.iter().partition::<Vec<_>, _>(|i| i.inner_impl().synthetic);
let (blanket_impl, concrete): (Vec<&Impl>, Vec<&Impl>) = concrete
.into_iter()
.partition::<Vec<_>, _>(|i| i.inner_impl().blanket_impl.is_some());
v.iter().partition::<Vec<_>, _>(|i| i.inner_impl().is_auto_impl());
let (blanket_impl, concrete): (Vec<&Impl>, Vec<&Impl>) =
concrete.into_iter().partition::<Vec<_>, _>(|i| i.inner_impl().is_blanket_impl());
let concrete_format = format_impls(concrete);
let synthetic_format = format_impls(synthetic);