diff options
| author | Noah Lev <camelidcamel@gmail.com> | 2021-11-06 23:10:01 -0700 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2021-11-07 08:41:18 -0800 |
| commit | 7b7023cb723775fa20bda42e97dbc44abe7ecb0c (patch) | |
| tree | 2e2407a5108e2369989d9b28a33b717d5e2661b7 /src/librustdoc/html | |
| parent | c32ee54380bfa39cb300a330f1ce886b9f90eaaf (diff) | |
| download | rust-7b7023cb723775fa20bda42e97dbc44abe7ecb0c.tar.gz rust-7b7023cb723775fa20bda42e97dbc44abe7ecb0c.zip | |
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.
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/format.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 11 | ||||
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/render/write_shared.rs | 2 |
4 files changed, 8 insertions, 9 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index c51bda60b73..5a4ff8dc837 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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)?; diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 25fef114d95..91bd1107d87 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -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); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index d07ef6db4c6..10afe18b33c 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -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)); diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 978701746b7..cf12d668569 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -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), }) } |
