remove Clean trait implementation for hir::GenericArgs

This commit is contained in:
Guillaume Gomez 2022-08-10 14:46:18 +02:00
parent a4f52a5622
commit 0cd06fb481

View File

@ -123,7 +123,7 @@ fn clean_generic_bound<'tcx>(
let trait_ref = ty::TraitRef::identity(cx.tcx, def_id).skip_binder(); let trait_ref = ty::TraitRef::identity(cx.tcx, def_id).skip_binder();
let generic_args = generic_args.clean(cx); let generic_args = clean_generic_args(generic_args, cx);
let GenericArgs::AngleBracketed { bindings, .. } = generic_args let GenericArgs::AngleBracketed { bindings, .. } = generic_args
else { else {
bug!("clean: parenthesized `GenericBound::LangItemTrait`"); bug!("clean: parenthesized `GenericBound::LangItemTrait`");
@ -1826,16 +1826,18 @@ 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() } Path { res: path.res, segments: path.segments.iter().map(|x| x.clean(cx)).collect() }
} }
impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> { fn clean_generic_args<'tcx>(
fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericArgs { generic_args: &hir::GenericArgs<'tcx>,
if self.parenthesized { cx: &mut DocContext<'tcx>,
let output = clean_ty(self.bindings[0].ty(), cx); ) -> GenericArgs {
let output = if generic_args.parenthesized {
if output != Type::Tuple(Vec::new()) { Some(Box::new(output)) } else { None }; let output = clean_ty(generic_args.bindings[0].ty(), cx);
let inputs = self.inputs().iter().map(|x| clean_ty(x, cx)).collect::<Vec<_>>().into(); let output = if output != Type::Tuple(Vec::new()) { Some(Box::new(output)) } else { None };
let inputs =
generic_args.inputs().iter().map(|x| clean_ty(x, cx)).collect::<Vec<_>>().into();
GenericArgs::Parenthesized { inputs, output } GenericArgs::Parenthesized { inputs, output }
} else { } else {
let args = self let args = generic_args
.args .args
.iter() .iter()
.map(|arg| match arg { .map(|arg| match arg {
@ -1849,16 +1851,19 @@ impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> {
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into(); .into();
let bindings = let bindings = generic_args
self.bindings.iter().map(|x| clean_type_binding(x, cx)).collect::<Vec<_>>().into(); .bindings
.iter()
.map(|x| clean_type_binding(x, cx))
.collect::<Vec<_>>()
.into();
GenericArgs::AngleBracketed { args, bindings } GenericArgs::AngleBracketed { args, bindings }
} }
}
} }
impl<'tcx> Clean<'tcx, PathSegment> for hir::PathSegment<'tcx> { impl<'tcx> Clean<'tcx, PathSegment> for hir::PathSegment<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> PathSegment { fn clean(&self, cx: &mut DocContext<'tcx>) -> PathSegment {
PathSegment { name: self.ident.name, args: self.args().clean(cx) } PathSegment { name: self.ident.name, args: clean_generic_args(self.args(), cx) }
} }
} }
@ -2228,7 +2233,10 @@ fn clean_type_binding<'tcx>(
cx: &mut DocContext<'tcx>, cx: &mut DocContext<'tcx>,
) -> TypeBinding { ) -> TypeBinding {
TypeBinding { TypeBinding {
assoc: PathSegment { name: type_binding.ident.name, args: type_binding.gen_args.clean(cx) }, assoc: PathSegment {
name: type_binding.ident.name,
args: clean_generic_args(type_binding.gen_args, cx),
},
kind: match type_binding.kind { kind: match type_binding.kind {
hir::TypeBindingKind::Equality { ref term } => { hir::TypeBindingKind::Equality { ref term } => {
TypeBindingKind::Equality { term: clean_hir_term(term, cx) } TypeBindingKind::Equality { term: clean_hir_term(term, cx) }