Skip to content

Commit 169b84f

Browse files
committed
Replace where-bounded Clean impl with function
This was the only Clean impl I found with `where` bounds. This impl was doubly-confusing: it was implemented on a tuple and it was polymorphic. Combined, this caused a "spooky action at a distance" effect to make the code very confusing.
1 parent c57704f commit 169b84f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,9 @@ fn clean_fn_or_proc_macro(
761761

762762
impl<'a> Clean<Function> for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::BodyId) {
763763
fn clean(&self, cx: &mut DocContext<'_>) -> Function {
764-
let (generics, decl) =
765-
enter_impl_trait(cx, |cx| (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx)));
764+
let (generics, decl) = enter_impl_trait(cx, |cx| {
765+
(self.1.clean(cx), clean_fn_decl_with_args(cx, &*self.0.decl, self.2))
766+
});
766767
Function { decl, generics, header: self.0.header }
767768
}
768769
}
@@ -804,16 +805,18 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
804805
}
805806
}
806807

807-
impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl<'a>, A)
808+
fn clean_fn_decl_with_args<'a, A: Copy>(
809+
cx: &mut DocContext<'_>,
810+
decl: &'a hir::FnDecl<'a>,
811+
args: A,
812+
) -> FnDecl
808813
where
809814
(&'a [hir::Ty<'a>], A): Clean<Arguments>,
810815
{
811-
fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl {
812-
FnDecl {
813-
inputs: (self.0.inputs, self.1).clean(cx),
814-
output: self.0.output.clean(cx),
815-
c_variadic: self.0.c_variadic,
816-
}
816+
FnDecl {
817+
inputs: (decl.inputs, args).clean(cx),
818+
output: decl.output.clean(cx),
819+
c_variadic: decl.c_variadic,
817820
}
818821
}
819822

@@ -894,7 +897,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
894897
}
895898
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => {
896899
let (generics, decl) = enter_impl_trait(cx, |cx| {
897-
(self.generics.clean(cx), (sig.decl, names).clean(cx))
900+
(self.generics.clean(cx), clean_fn_decl_with_args(cx, sig.decl, names))
898901
});
899902
let mut t = Function { header: sig.header, decl, generics };
900903
if t.header.constness == hir::Constness::Const
@@ -1728,7 +1731,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
17281731
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
17291732
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
17301733
let generic_params = self.generic_params.iter().map(|x| x.clean(cx)).collect();
1731-
let decl = (self.decl, self.param_names).clean(cx);
1734+
let decl = clean_fn_decl_with_args(cx, self.decl, self.param_names);
17321735
(generic_params, decl)
17331736
});
17341737
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
@@ -2025,8 +2028,9 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
20252028
let kind = match item.kind {
20262029
hir::ForeignItemKind::Fn(decl, names, ref generics) => {
20272030
let abi = cx.tcx.hir().get_foreign_abi(item.hir_id());
2028-
let (generics, decl) =
2029-
enter_impl_trait(cx, |cx| (generics.clean(cx), (decl, names).clean(cx)));
2031+
let (generics, decl) = enter_impl_trait(cx, |cx| {
2032+
(generics.clean(cx), clean_fn_decl_with_args(cx, decl, names))
2033+
});
20302034
ForeignFunctionItem(Function {
20312035
decl,
20322036
generics,

0 commit comments

Comments
 (0)