1
Fork 0

remove Clean trait implementation for hir::BareFnTy

This commit is contained in:
Guillaume Gomez 2022-08-12 11:40:39 +02:00
parent a65647a7f6
commit 001cc12af7

View file

@ -1510,7 +1510,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
if !lifetime.is_elided() { Some(clean_lifetime(*lifetime, cx)) } else { None }; if !lifetime.is_elided() { Some(clean_lifetime(*lifetime, cx)) } else { None };
DynTrait(bounds, lifetime) DynTrait(bounds, lifetime)
} }
TyKind::BareFn(barefn) => BareFunction(Box::new(barefn.clean(cx))), TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s. // Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
TyKind::Infer | TyKind::Err => Infer, TyKind::Infer | TyKind::Err => Infer,
TyKind::Typeof(..) => panic!("unimplemented type {:?}", ty.kind), TyKind::Typeof(..) => panic!("unimplemented type {:?}", ty.kind),
@ -1874,22 +1874,23 @@ fn clean_path_segment<'tcx>(
PathSegment { name: path.ident.name, args: clean_generic_args(path.args(), cx) } PathSegment { name: path.ident.name, args: clean_generic_args(path.args(), cx) }
} }
impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> { fn clean_bare_fn_ty<'tcx>(
fn clean(&self, cx: &mut DocContext<'tcx>) -> BareFunctionDecl { bare_fn: &hir::BareFnTy<'tcx>,
let (generic_params, decl) = enter_impl_trait(cx, |cx| { cx: &mut DocContext<'tcx>,
// NOTE: generics must be cleaned before args ) -> BareFunctionDecl {
let generic_params = self let (generic_params, decl) = enter_impl_trait(cx, |cx| {
.generic_params // NOTE: generics must be cleaned before args
.iter() let generic_params = bare_fn
.filter(|p| !is_elided_lifetime(p)) .generic_params
.map(|x| clean_generic_param(cx, None, x)) .iter()
.collect(); .filter(|p| !is_elided_lifetime(p))
let args = clean_args_from_types_and_names(cx, self.decl.inputs, self.param_names); .map(|x| clean_generic_param(cx, None, x))
let decl = clean_fn_decl_with_args(cx, self.decl, args); .collect();
(generic_params, decl) let args = clean_args_from_types_and_names(cx, bare_fn.decl.inputs, bare_fn.param_names);
}); let decl = clean_fn_decl_with_args(cx, bare_fn.decl, args);
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params } (generic_params, decl)
} });
BareFunctionDecl { unsafety: bare_fn.unsafety, abi: bare_fn.abi, decl, generic_params }
} }
fn clean_maybe_renamed_item<'tcx>( fn clean_maybe_renamed_item<'tcx>(