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:
parent
c32ee54380
commit
7b7023cb72
12 changed files with 66 additions and 36 deletions
|
|
@ -997,7 +997,7 @@ impl clean::Impl {
|
|||
write!(f, " for ")?;
|
||||
}
|
||||
|
||||
if let Some(ref ty) = self.blanket_impl {
|
||||
if let Some(ref ty) = self.blanket_impl_ty() {
|
||||
fmt_type(ty, f, use_absolute, cx)?;
|
||||
} else {
|
||||
fmt_type(&self.for_, f, use_absolute, cx)?;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
|||
});
|
||||
|
||||
let (mut synthetic, mut concrete): (Vec<&&Impl>, Vec<&&Impl>) =
|
||||
local.iter().partition(|i| i.inner_impl().synthetic);
|
||||
local.iter().partition(|i| i.inner_impl().is_auto_impl());
|
||||
|
||||
synthetic.sort_by(|a, b| compare_impl(a, b, cx));
|
||||
concrete.sort_by(|a, b| compare_impl(a, b, cx));
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ pub(super) fn write_shared(
|
|||
} else {
|
||||
Some(Implementor {
|
||||
text: imp.inner_impl().print(false, cx).to_string(),
|
||||
synthetic: imp.inner_impl().synthetic,
|
||||
synthetic: imp.inner_impl().is_auto_impl(),
|
||||
types: collect_paths_for_type(imp.inner_impl().for_.clone(), cache),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue