Skip to content

Commit

Permalink
rustdoc: Remove top-level wrappers for ImplKind methods
Browse files Browse the repository at this point in the history
The `ImplKind` methods can just be used directly instead.
  • Loading branch information
camelid committed Nov 8, 2021
1 parent 7c7bf45 commit b5817fa
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 20 deletions.
12 changes: 0 additions & 12 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2182,18 +2182,6 @@ crate struct Impl {
}

impl Impl {
crate fn is_auto_impl(&self) -> bool {
self.kind.is_auto()
}

crate fn is_blanket_impl(&self) -> bool {
self.kind.is_blanket()
}

crate fn blanket_impl_ty(&self) -> Option<&Type> {
self.kind.as_blanket_ty()
}

crate fn provided_trait_methods(&self, tcx: TyCtxt<'_>) -> FxHashSet<Symbol> {
self.trait_
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
// Collect all the implementors of traits.
if let clean::ImplItem(ref i) = *item.kind {
if let Some(trait_) = &i.trait_ {
if !i.is_blanket_impl() {
if !i.kind.is_blanket() {
self.cache
.implementors
.entry(trait_.def_id())
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ impl clean::Impl {
write!(f, " for ")?;
}

if let Some(ref ty) = self.blanket_impl_ty() {
if let Some(ref ty) = self.kind.as_blanket_ty() {
fmt_type(ty, f, use_absolute, cx)?;
} else {
fmt_type(&self.for_, f, use_absolute, cx)?;
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,9 @@ fn render_assoc_items_inner(
}

let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) =
traits.iter().partition(|t| t.inner_impl().is_auto_impl());
traits.iter().partition(|t| t.inner_impl().kind.is_auto());
let (blanket_impl, concrete): (Vec<&&Impl>, _) =
concrete.into_iter().partition(|t| t.inner_impl().is_blanket_impl());
concrete.into_iter().partition(|t| t.inner_impl().kind.is_blanket());

let mut impls = Buffer::empty_from(w);
render_impls(cx, &mut impls, &concrete, containing_item);
Expand Down Expand Up @@ -2059,9 +2059,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().is_auto_impl());
v.iter().partition::<Vec<_>, _>(|i| i.inner_impl().kind.is_auto());
let (blanket_impl, concrete): (Vec<&Impl>, Vec<&Impl>) =
concrete.into_iter().partition::<Vec<_>, _>(|i| i.inner_impl().is_blanket_impl());
concrete.into_iter().partition::<Vec<_>, _>(|i| i.inner_impl().kind.is_blanket());

let concrete_format = format_impls(concrete);
let synthetic_format = format_impls(synthetic);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().is_auto_impl());
local.iter().partition(|i| i.inner_impl().kind.is_auto());

synthetic.sort_by(|a, b| compare_impl(a, b, cx));
concrete.sort_by(|a, b| compare_impl(a, b, cx));
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().is_auto_impl(),
synthetic: imp.inner_impl().kind.is_auto(),
types: collect_paths_for_type(imp.inner_impl().for_.clone(), cache),
})
}
Expand Down

0 comments on commit b5817fa

Please sign in to comment.