From 279af1d7e06b5b5dcb0d0538d6f11ad5e974127a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 31 Jul 2022 14:17:23 +0200 Subject: [PATCH 1/3] Remove Clean trait implementation for hir::Path --- src/librustdoc/clean/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 4067cf8441b3d..0d2a2d92725d7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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 } @@ -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) } } @@ -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); @@ -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> { @@ -2172,7 +2170,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(); From 9dd59ddfbf8e6b2c33da513c9d1aeb17ef81bccb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 31 Jul 2022 14:21:07 +0200 Subject: [PATCH 2/3] Remove Clean trait implementation for hir::TypeBinding --- src/librustdoc/clean/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0d2a2d92725d7..1503873473913 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1884,7 +1884,8 @@ impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> { }) .collect::>() .into(); - let bindings = self.bindings.iter().map(|x| x.clean(cx)).collect::>().into(); + let bindings = + self.bindings.iter().map(|x| clean_type_binding(x, cx)).collect::>().into(); GenericArgs::AngleBracketed { args, bindings } } } @@ -2250,12 +2251,13 @@ 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), - } +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: type_binding.kind.clean(cx), } } From fc1c858a48c212c657d59d09a604481c17369e6b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 31 Jul 2022 14:24:13 +0200 Subject: [PATCH 3/3] Remove Clean trait implementation for hir::TypeBindingKind --- src/librustdoc/clean/mod.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1503873473913..5071581e5dc43 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2257,19 +2257,13 @@ fn clean_type_binding<'tcx>( ) -> TypeBinding { TypeBinding { assoc: PathSegment { name: type_binding.ident.name, args: type_binding.gen_args.clean(cx) }, - kind: type_binding.kind.clean(cx), - } -} - -impl<'tcx> Clean<'tcx, TypeBindingKind> for hir::TypeBindingKind<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBindingKind { - match *self { + 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(), }, - } + }, } }