Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Replace where-bounded Clean impl with simple function #90750

Merged
merged 4 commits into from
Nov 18, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
};

GenericBound::TraitBound(
PolyTrait { trait_: (trait_ref, &*bindings).clean(cx), generic_params: vec![] },
PolyTrait {
trait_: (trait_ref, &bindings[..]).clean(cx),
generic_params: vec![],
},
hir::TraitBoundModifier::None,
)
}
Expand Down Expand Up @@ -761,8 +764,12 @@ fn clean_fn_or_proc_macro(

impl<'a> Clean<Function> for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::BodyId) {
fn clean(&self, cx: &mut DocContext<'_>) -> Function {
let (generics, decl) =
enter_impl_trait(cx, |cx| (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx)));
let (generics, decl) = enter_impl_trait(cx, |cx| {
let generics = self.1.clean(cx);
let args = (self.0.decl.inputs, self.2).clean(cx);
let decl = clean_fn_decl_with_args(cx, self.0.decl, args);
(generics, decl)
});
Function { decl, generics, header: self.0.header }
}
}
Expand Down Expand Up @@ -804,17 +811,12 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
}
}

impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl<'a>, A)
where
(&'a [hir::Ty<'a>], A): Clean<Arguments>,
{
fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl {
FnDecl {
inputs: (self.0.inputs, self.1).clean(cx),
output: self.0.output.clean(cx),
c_variadic: self.0.c_variadic,
}
}
fn clean_fn_decl_with_args(
cx: &mut DocContext<'_>,
decl: &hir::FnDecl<'_>,
args: Arguments,
) -> FnDecl {
FnDecl { inputs: args, output: decl.output.clean(cx), c_variadic: decl.c_variadic }
}

impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
Expand Down Expand Up @@ -894,7 +896,10 @@ impl Clean<Item> for hir::TraitItem<'_> {
}
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => {
let (generics, decl) = enter_impl_trait(cx, |cx| {
(self.generics.clean(cx), (sig.decl, names).clean(cx))
let generics = self.generics.clean(cx);
let args = (sig.decl.inputs, names).clean(cx);
let decl = clean_fn_decl_with_args(cx, sig.decl, args);
(generics, decl)
});
let mut t = Function { header: sig.header, decl, generics };
if t.header.constness == hir::Constness::Const
Expand Down Expand Up @@ -1728,7 +1733,8 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
let generic_params = self.generic_params.iter().map(|x| x.clean(cx)).collect();
let decl = (self.decl, self.param_names).clean(cx);
let args = (self.decl.inputs, self.param_names).clean(cx);
let decl = clean_fn_decl_with_args(cx, self.decl, args);
(generic_params, decl)
});
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
Expand Down Expand Up @@ -2025,8 +2031,12 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
let kind = match item.kind {
hir::ForeignItemKind::Fn(decl, names, ref generics) => {
let abi = cx.tcx.hir().get_foreign_abi(item.hir_id());
let (generics, decl) =
enter_impl_trait(cx, |cx| (generics.clean(cx), (decl, names).clean(cx)));
let (generics, decl) = enter_impl_trait(cx, |cx| {
let generics = generics.clean(cx);
let args = (decl.inputs, names).clean(cx);
let decl = clean_fn_decl_with_args(cx, decl, args);
(generics, decl)
});
ForeignFunctionItem(Function {
decl,
generics,
Expand Down