Skip to content

Commit

Permalink
Rollup merge of #99980 - GuillaumeGomez:rm-clean-impls, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Remove more Clean trait implementations

This time as well it allowed to remove a function.

Follow-up of #99638.

r? `@notriddle`
  • Loading branch information
matthiaskrgr authored Jul 31, 2022
2 parents 549463f + fc1c858 commit 0c3989e
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ impl<'tcx> Clean<'tcx, bool> for hir::IsAuto {

impl<'tcx> Clean<'tcx, Path> for hir::TraitRef<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> Path {
let path = self.path.clean(cx);
let path = clean_path(self.path, cx);
register_res(cx, path.res);
path
}
Expand Down Expand Up @@ -1344,7 +1344,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
if let Some(expanded) = maybe_expand_private_type_alias(cx, path) {
expanded
} else {
let path = path.clean(cx);
let path = clean_path(path, cx);
resolve_type(cx, path)
}
}
Expand Down Expand Up @@ -1380,7 +1380,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
ty::Error(_) => return Type::Infer,
_ => bug!("clean: expected associated type, found `{:?}`", ty),
};
let trait_ = hir::Path { span, res, segments: &[] }.clean(cx);
let trait_ = clean_path(&hir::Path { span, res, segments: &[] }, cx);
register_res(cx, trait_.res);
let self_def_id = res.opt_def_id();
let self_type = clean_ty(qself, cx);
Expand Down Expand Up @@ -1857,10 +1857,8 @@ fn clean_variant_data<'tcx>(
}
}

impl<'tcx> Clean<'tcx, Path> for hir::Path<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> Path {
Path { res: self.res, segments: self.segments.iter().map(|x| x.clean(cx)).collect() }
}
fn clean_path<'tcx>(path: &hir::Path<'tcx>, cx: &mut DocContext<'tcx>) -> Path {
Path { res: path.res, segments: path.segments.iter().map(|x| x.clean(cx)).collect() }
}

impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> {
Expand All @@ -1886,7 +1884,8 @@ impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> {
})
.collect::<Vec<_>>()
.into();
let bindings = self.bindings.iter().map(|x| x.clean(cx)).collect::<Vec<_>>().into();
let bindings =
self.bindings.iter().map(|x| clean_type_binding(x, cx)).collect::<Vec<_>>().into();
GenericArgs::AngleBracketed { args, bindings }
}
}
Expand Down Expand Up @@ -2172,7 +2171,7 @@ fn clean_use_statement<'tcx>(

// Also check whether imports were asked to be inlined, in case we're trying to re-export a
// crate in Rust 2018+
let path = path.clean(cx);
let path = clean_path(path, cx);
let inner = if kind == hir::UseKind::Glob {
if !denied {
let mut visited = FxHashSet::default();
Expand Down Expand Up @@ -2252,24 +2251,19 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
})
}

impl<'tcx> Clean<'tcx, TypeBinding> for hir::TypeBinding<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBinding {
TypeBinding {
assoc: PathSegment { name: self.ident.name, args: self.gen_args.clean(cx) },
kind: self.kind.clean(cx),
}
}
}

impl<'tcx> Clean<'tcx, TypeBindingKind> for hir::TypeBindingKind<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBindingKind {
match *self {
fn clean_type_binding<'tcx>(
type_binding: &hir::TypeBinding<'tcx>,
cx: &mut DocContext<'tcx>,
) -> TypeBinding {
TypeBinding {
assoc: PathSegment { name: type_binding.ident.name, args: type_binding.gen_args.clean(cx) },
kind: match type_binding.kind {
hir::TypeBindingKind::Equality { ref term } => {
TypeBindingKind::Equality { term: clean_hir_term(term, cx) }
}
hir::TypeBindingKind::Constraint { bounds } => TypeBindingKind::Constraint {
bounds: bounds.iter().filter_map(|b| b.clean(cx)).collect(),
},
}
},
}
}

0 comments on commit 0c3989e

Please sign in to comment.