Skip to content

Commit 38c6b13

Browse files
committed
Remove a Clean impl for a tuple (7)
1 parent 4ede1f8 commit 38c6b13

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

src/librustdoc/clean/inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_span::hygiene::MacroKind;
1515
use rustc_span::symbol::{kw, sym, Symbol};
1616

1717
use crate::clean::{
18-
self, clean_ty_generics, utils, Attributes, AttributesExt, Clean, ImplKind, ItemId,
19-
NestedAttributesExt, Type, Visibility,
18+
self, clean_fn_decl_from_did_and_sig, clean_ty_generics, utils, Attributes, AttributesExt,
19+
Clean, ImplKind, ItemId, NestedAttributesExt, Type, Visibility,
2020
};
2121
use crate::core::DocContext;
2222
use crate::formats::item_type::ItemType;
@@ -230,7 +230,7 @@ fn build_external_function(cx: &mut DocContext<'_>, did: DefId) -> clean::Functi
230230
let (generics, decl) = clean::enter_impl_trait(cx, |cx| {
231231
// NOTE: generics need to be cleaned before the decl!
232232
let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
233-
let decl = (did, sig).clean(cx);
233+
let decl = clean_fn_decl_from_did_and_sig(cx, did, sig);
234234
(generics, decl)
235235
});
236236
clean::Function {

src/librustdoc/clean/mod.rs

+25-23
Original file line numberDiff line numberDiff line change
@@ -838,27 +838,28 @@ fn clean_fn_decl_with_args(
838838
FnDecl { inputs: args, output: decl.output.clean(cx), c_variadic: decl.c_variadic }
839839
}
840840

841-
impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
842-
fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl {
843-
let (did, sig) = *self;
844-
let mut names = if did.is_local() { &[] } else { cx.tcx.fn_arg_names(did) }.iter();
845-
846-
FnDecl {
847-
output: Return(sig.skip_binder().output().clean(cx)),
848-
c_variadic: sig.skip_binder().c_variadic,
849-
inputs: Arguments {
850-
values: sig
851-
.skip_binder()
852-
.inputs()
853-
.iter()
854-
.map(|t| Argument {
855-
type_: t.clean(cx),
856-
name: names.next().map_or(kw::Empty, |i| i.name),
857-
is_const: false,
858-
})
859-
.collect(),
860-
},
861-
}
841+
fn clean_fn_decl_from_did_and_sig(
842+
cx: &mut DocContext<'_>,
843+
did: DefId,
844+
sig: ty::PolyFnSig<'_>,
845+
) -> FnDecl {
846+
let mut names = if did.is_local() { &[] } else { cx.tcx.fn_arg_names(did) }.iter();
847+
848+
FnDecl {
849+
output: Return(sig.skip_binder().output().clean(cx)),
850+
c_variadic: sig.skip_binder().c_variadic,
851+
inputs: Arguments {
852+
values: sig
853+
.skip_binder()
854+
.inputs()
855+
.iter()
856+
.map(|t| Argument {
857+
type_: t.clean(cx),
858+
name: names.next().map_or(kw::Empty, |i| i.name),
859+
is_const: false,
860+
})
861+
.collect(),
862+
},
862863
}
863864
}
864865

@@ -1013,7 +1014,7 @@ impl Clean<Item> for ty::AssocItem {
10131014
tcx.explicit_predicates_of(self.def_id),
10141015
);
10151016
let sig = tcx.fn_sig(self.def_id);
1016-
let mut decl = (self.def_id, sig).clean(cx);
1017+
let mut decl = clean_fn_decl_from_did_and_sig(cx, self.def_id, sig);
10171018

10181019
if self.fn_has_self_parameter {
10191020
let self_ty = match self.container {
@@ -1407,10 +1408,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14071408
let ty = cx.tcx.lift(*self).expect("FnPtr lift failed");
14081409
let sig = ty.fn_sig(cx.tcx);
14091410
let def_id = DefId::local(CRATE_DEF_INDEX);
1411+
let decl = clean_fn_decl_from_did_and_sig(cx, def_id, sig);
14101412
BareFunction(box BareFunctionDecl {
14111413
unsafety: sig.unsafety(),
14121414
generic_params: Vec::new(),
1413-
decl: (def_id, sig).clean(cx),
1415+
decl,
14141416
abi: sig.abi(),
14151417
})
14161418
}

0 commit comments

Comments
 (0)