From a442c1e0570e07892f9d9bb9c0716a957b155815 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Aug 2022 11:32:45 +0200 Subject: [PATCH 1/2] remove Clean trait implementation for hir::FnRetTy --- src/librustdoc/clean/mod.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5e81db363ee5c..33ce35a3e6b3c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -956,7 +956,11 @@ fn clean_fn_decl_with_args<'tcx>( decl: &hir::FnDecl<'tcx>, args: Arguments, ) -> FnDecl { - FnDecl { inputs: args, output: decl.output.clean(cx), c_variadic: decl.c_variadic } + let output = match decl.output { + hir::FnRetTy::Return(typ) => Return(clean_ty(typ, cx)), + hir::FnRetTy::DefaultReturn(..) => DefaultReturn, + }; + FnDecl { inputs: args, output, c_variadic: decl.c_variadic } } fn clean_fn_decl_from_did_and_sig<'tcx>( @@ -991,15 +995,6 @@ fn clean_fn_decl_from_did_and_sig<'tcx>( } } -impl<'tcx> Clean<'tcx, FnRetTy> for hir::FnRetTy<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> FnRetTy { - match *self { - Self::Return(typ) => Return(clean_ty(typ, cx)), - Self::DefaultReturn(..) => DefaultReturn, - } - } -} - impl<'tcx> Clean<'tcx, Path> for hir::TraitRef<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> Path { let path = clean_path(self.path, cx); From 008693d23160dcbce4cf86116acbac00ba734947 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Aug 2022 11:43:50 +0200 Subject: [PATCH 2/2] remove Clean trait implementation for hir::TraitRef --- 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 33ce35a3e6b3c..790727c918a1f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -995,18 +995,16 @@ fn clean_fn_decl_from_did_and_sig<'tcx>( } } -impl<'tcx> Clean<'tcx, Path> for hir::TraitRef<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Path { - let path = clean_path(self.path, cx); - register_res(cx, path.res); - path - } +fn clean_trait_ref<'tcx>(trait_ref: &hir::TraitRef<'tcx>, cx: &mut DocContext<'tcx>) -> Path { + let path = clean_path(trait_ref.path, cx); + register_res(cx, path.res); + path } impl<'tcx> Clean<'tcx, PolyTrait> for hir::PolyTraitRef<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> PolyTrait { PolyTrait { - trait_: self.trait_ref.clean(cx), + trait_: clean_trait_ref(&self.trait_ref, cx), generic_params: self .bound_generic_params .iter() @@ -1995,7 +1993,7 @@ fn clean_impl<'tcx>( ) -> Vec { let tcx = cx.tcx; let mut ret = Vec::new(); - let trait_ = impl_.of_trait.as_ref().map(|t| t.clean(cx)); + let trait_ = impl_.of_trait.as_ref().map(|t| clean_trait_ref(t, cx)); let items = impl_.items.iter().map(|ii| tcx.hir().impl_item(ii.id).clean(cx)).collect::>(); let def_id = tcx.hir().local_def_id(hir_id);