mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-23 22:14:15 +00:00
Remove Clean impl for Vec<T>
This commit is contained in:
parent
efe4d7ca7e
commit
72b0a57244
@ -121,8 +121,8 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
.tcx
|
||||
.associated_items(impl_def_id)
|
||||
.in_definition_order()
|
||||
.collect::<Vec<_>>()
|
||||
.clean(self.cx),
|
||||
.map(|x| x.clean(self.cx))
|
||||
.collect::<Vec<_>>(),
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
kind: ImplKind::Blanket(box trait_ref.self_ty().clean(self.cx)),
|
||||
}),
|
||||
|
@ -255,7 +255,7 @@ fn build_struct(cx: &mut DocContext<'_>, did: DefId) -> clean::Struct {
|
||||
clean::Struct {
|
||||
struct_type: variant.ctor_kind,
|
||||
generics: (cx.tcx.generics_of(did), predicates).clean(cx),
|
||||
fields: variant.fields.clean(cx),
|
||||
fields: variant.fields.iter().map(|x| x.clean(cx)).collect(),
|
||||
fields_stripped: false,
|
||||
}
|
||||
}
|
||||
@ -264,11 +264,9 @@ fn build_union(cx: &mut DocContext<'_>, did: DefId) -> clean::Union {
|
||||
let predicates = cx.tcx.explicit_predicates_of(did);
|
||||
let variant = cx.tcx.adt_def(did).non_enum_variant();
|
||||
|
||||
clean::Union {
|
||||
generics: (cx.tcx.generics_of(did), predicates).clean(cx),
|
||||
fields: variant.fields.clean(cx),
|
||||
fields_stripped: false,
|
||||
}
|
||||
let generics = (cx.tcx.generics_of(did), predicates).clean(cx);
|
||||
let fields = variant.fields.iter().map(|x| x.clean(cx)).collect();
|
||||
clean::Union { generics, fields, fields_stripped: false }
|
||||
}
|
||||
|
||||
fn build_type_alias(cx: &mut DocContext<'_>, did: DefId) -> clean::Typedef {
|
||||
|
@ -55,12 +55,6 @@ crate trait Clean<T> {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> T;
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<Vec<U>> for [T] {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> Vec<U> {
|
||||
self.iter().map(|x| x.clean(cx)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<U> for &T {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> U {
|
||||
(**self).clean(cx)
|
||||
@ -274,14 +268,14 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
|
||||
.collect();
|
||||
WherePredicate::BoundPredicate {
|
||||
ty: wbp.bounded_ty.clean(cx),
|
||||
bounds: wbp.bounds.clean(cx),
|
||||
bounds: wbp.bounds.iter().map(|x| x.clean(cx)).collect(),
|
||||
bound_params,
|
||||
}
|
||||
}
|
||||
|
||||
hir::WherePredicate::RegionPredicate(ref wrp) => WherePredicate::RegionPredicate {
|
||||
lifetime: wrp.lifetime.clean(cx),
|
||||
bounds: wrp.bounds.clean(cx),
|
||||
bounds: wrp.bounds.iter().map(|x| x.clean(cx)).collect(),
|
||||
},
|
||||
|
||||
hir::WherePredicate::EqPredicate(ref wrp) => {
|
||||
@ -446,7 +440,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
|
||||
self.name.ident().name,
|
||||
GenericParamDefKind::Type {
|
||||
did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(),
|
||||
bounds: self.bounds.clean(cx),
|
||||
bounds: self.bounds.iter().map(|x| x.clean(cx)).collect(),
|
||||
default: default.map(|t| t.clean(cx)).map(Box::new),
|
||||
synthetic,
|
||||
},
|
||||
@ -517,8 +511,10 @@ impl Clean<Generics> for hir::Generics<'_> {
|
||||
}
|
||||
params.extend(impl_trait_params);
|
||||
|
||||
let mut generics =
|
||||
Generics { params, where_predicates: self.where_clause.predicates.clean(cx) };
|
||||
let mut generics = Generics {
|
||||
params,
|
||||
where_predicates: self.where_clause.predicates.iter().map(|x| x.clean(cx)).collect(),
|
||||
};
|
||||
|
||||
// Some duplicates are generated for ?Sized bounds between type params and where
|
||||
// predicates. The point in here is to move the bounds definitions from type params
|
||||
@ -887,7 +883,7 @@ impl Clean<PolyTrait> for hir::PolyTraitRef<'_> {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> PolyTrait {
|
||||
PolyTrait {
|
||||
trait_: self.trait_ref.clean(cx),
|
||||
generic_params: self.bound_generic_params.clean(cx),
|
||||
generic_params: self.bound_generic_params.iter().map(|x| x.clean(cx)).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -922,7 +918,9 @@ impl Clean<Item> for hir::TraitItem<'_> {
|
||||
TyMethodItem(t)
|
||||
}
|
||||
hir::TraitItemKind::Type(bounds, ref default) => {
|
||||
AssocTypeItem(bounds.clean(cx), default.map(|t| t.clean(cx)))
|
||||
let bounds = bounds.iter().map(|x| x.clean(cx)).collect();
|
||||
let default = default.map(|t| t.clean(cx));
|
||||
AssocTypeItem(bounds, default)
|
||||
}
|
||||
};
|
||||
let what_rustc_thinks =
|
||||
@ -1256,7 +1254,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
|
||||
let trait_def = cx.tcx.associated_item(p.res.def_id()).container.id();
|
||||
let trait_ = self::Path {
|
||||
res: Res::Def(DefKind::Trait, trait_def),
|
||||
segments: trait_segments.clean(cx),
|
||||
segments: trait_segments.iter().map(|x| x.clean(cx)).collect(),
|
||||
};
|
||||
register_res(cx, trait_.res);
|
||||
Type::QPath {
|
||||
@ -1322,11 +1320,11 @@ impl Clean<Type> for hir::Ty<'_> {
|
||||
let length = print_const(cx, ct.eval(cx.tcx, param_env));
|
||||
Array(box ty.clean(cx), length)
|
||||
}
|
||||
TyKind::Tup(tys) => Tuple(tys.clean(cx)),
|
||||
TyKind::Tup(tys) => Tuple(tys.iter().map(|x| x.clean(cx)).collect()),
|
||||
TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = cx.tcx.hir().item(item_id);
|
||||
if let hir::ItemKind::OpaqueTy(ref ty) = item.kind {
|
||||
ImplTrait(ty.bounds.clean(cx))
|
||||
ImplTrait(ty.bounds.iter().map(|x| x.clean(cx)).collect())
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
@ -1466,7 +1464,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
|
||||
DynTrait(bounds, lifetime)
|
||||
}
|
||||
ty::Tuple(t) => Tuple(t.iter().map(|t| t.expect_ty()).collect::<Vec<_>>().clean(cx)),
|
||||
ty::Tuple(t) => Tuple(t.iter().map(|t| t.expect_ty().clean(cx)).collect()),
|
||||
|
||||
ty::Projection(ref data) => data.clean(cx),
|
||||
|
||||
@ -1699,7 +1697,7 @@ impl Clean<Variant> for hir::VariantData<'_> {
|
||||
|
||||
impl Clean<Path> for hir::Path<'_> {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> Path {
|
||||
Path { res: self.res, segments: self.segments.clean(cx) }
|
||||
Path { res: self.res, segments: self.segments.iter().map(|x| x.clean(cx)).collect() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1709,24 +1707,24 @@ impl Clean<GenericArgs> for hir::GenericArgs<'_> {
|
||||
let output = self.bindings[0].ty().clean(cx);
|
||||
let output =
|
||||
if output != Type::Tuple(Vec::new()) { Some(Box::new(output)) } else { None };
|
||||
GenericArgs::Parenthesized { inputs: self.inputs().clean(cx), output }
|
||||
let inputs = self.inputs().iter().map(|x| x.clean(cx)).collect();
|
||||
GenericArgs::Parenthesized { inputs, output }
|
||||
} else {
|
||||
GenericArgs::AngleBracketed {
|
||||
args: self
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| match arg {
|
||||
hir::GenericArg::Lifetime(lt) if !lt.is_elided() => {
|
||||
GenericArg::Lifetime(lt.clean(cx))
|
||||
}
|
||||
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
|
||||
hir::GenericArg::Type(ty) => GenericArg::Type(ty.clean(cx)),
|
||||
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(ct.clean(cx))),
|
||||
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
|
||||
})
|
||||
.collect(),
|
||||
bindings: self.bindings.clean(cx),
|
||||
}
|
||||
let args = self
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| match arg {
|
||||
hir::GenericArg::Lifetime(lt) if !lt.is_elided() => {
|
||||
GenericArg::Lifetime(lt.clean(cx))
|
||||
}
|
||||
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
|
||||
hir::GenericArg::Type(ty) => GenericArg::Type(ty.clean(cx)),
|
||||
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(ct.clean(cx))),
|
||||
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
|
||||
})
|
||||
.collect();
|
||||
let bindings = self.bindings.iter().map(|x| x.clean(cx)).collect();
|
||||
GenericArgs::AngleBracketed { args, bindings }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1740,7 +1738,9 @@ impl Clean<PathSegment> for hir::PathSegment<'_> {
|
||||
impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
|
||||
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
|
||||
(self.generic_params.clean(cx), (&*self.decl, self.param_names).clean(cx))
|
||||
let generic_params = self.generic_params.iter().map(|x| x.clean(cx)).collect();
|
||||
let decl = (self.decl, self.param_names).clean(cx);
|
||||
(generic_params, decl)
|
||||
});
|
||||
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
|
||||
}
|
||||
@ -1763,7 +1763,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
|
||||
kind: ConstantKind::Local { body: body_id, def_id },
|
||||
}),
|
||||
ItemKind::OpaqueTy(ref ty) => OpaqueTyItem(OpaqueTy {
|
||||
bounds: ty.bounds.clean(cx),
|
||||
bounds: ty.bounds.iter().map(|x| x.clean(cx)).collect(),
|
||||
generics: ty.generics.clean(cx),
|
||||
}),
|
||||
ItemKind::TyAlias(hir_ty, ref generics) => {
|
||||
@ -1785,17 +1785,17 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
|
||||
}),
|
||||
ItemKind::TraitAlias(ref generics, bounds) => TraitAliasItem(TraitAlias {
|
||||
generics: generics.clean(cx),
|
||||
bounds: bounds.clean(cx),
|
||||
bounds: bounds.iter().map(|x| x.clean(cx)).collect(),
|
||||
}),
|
||||
ItemKind::Union(ref variant_data, ref generics) => UnionItem(Union {
|
||||
generics: generics.clean(cx),
|
||||
fields: variant_data.fields().clean(cx),
|
||||
fields: variant_data.fields().iter().map(|x| x.clean(cx)).collect(),
|
||||
fields_stripped: false,
|
||||
}),
|
||||
ItemKind::Struct(ref variant_data, ref generics) => StructItem(Struct {
|
||||
struct_type: CtorKind::from_hir(variant_data),
|
||||
generics: generics.clean(cx),
|
||||
fields: variant_data.fields().clean(cx),
|
||||
fields: variant_data.fields().iter().map(|x| x.clean(cx)).collect(),
|
||||
fields_stripped: false,
|
||||
}),
|
||||
ItemKind::Impl(ref impl_) => return clean_impl(impl_, item.hir_id(), cx),
|
||||
@ -1815,7 +1815,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
|
||||
unsafety,
|
||||
items,
|
||||
generics: generics.clean(cx),
|
||||
bounds: bounds.clean(cx),
|
||||
bounds: bounds.iter().map(|x| x.clean(cx)).collect(),
|
||||
is_auto: is_auto.clean(cx),
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user