.get(&item.def_id)
.into_iter()
.flatten()
- .filter_map(|clean::ItemLink { link, did, .. }| {
- did.map(|did| (link.clone(), from_item_id(did.into())))
- })
+ .map(|clean::ItemLink { link, did, .. }| (link.clone(), from_item_id((*did).into())))
.collect();
let docs = item.attrs.collapsed_doc_value();
let attrs = item
},
Parenthesized { inputs, output } => GenericArgs::Parenthesized {
inputs: inputs.into_iter().map(|a| a.into_tcx(tcx)).collect(),
- output: output.map(|a| a.into_tcx(tcx)),
+ output: output.map(|a| (*a).into_tcx(tcx)),
},
}
}
match arg {
Lifetime(l) => GenericArg::Lifetime(l.0.to_string()),
Type(t) => GenericArg::Type(t.into_tcx(tcx)),
- Const(c) => GenericArg::Const(c.into_tcx(tcx)),
+ Const(box c) => GenericArg::Const(c.into_tcx(tcx)),
Infer => GenericArg::Infer,
}
}
fn from_tcx(kind: clean::GenericParamDefKind, tcx: TyCtxt<'_>) -> Self {
use clean::GenericParamDefKind::*;
match kind {
- Lifetime => GenericParamDefKind::Lifetime,
+ Lifetime { outlives } => GenericParamDefKind::Lifetime {
+ outlives: outlives.into_iter().map(|lt| lt.0.to_string()).collect(),
+ },
Type { did: _, bounds, default, synthetic: _ } => GenericParamDefKind::Type {
bounds: bounds.into_iter().map(|x| x.into_tcx(tcx)).collect(),
default: default.map(|x| x.into_tcx(tcx)),
use clean::GenericBound::*;
match bound {
TraitBound(clean::PolyTrait { trait_, generic_params }, modifier) => {
+ // FIXME: should `trait_` be a clean::Path equivalent in JSON?
+ let trait_ =
+ clean::ResolvedPath { did: trait_.res.def_id(), path: trait_ }.into_tcx(tcx);
GenericBound::TraitBound {
- trait_: trait_.into_tcx(tcx),
+ trait_,
generic_params: generic_params.into_iter().map(|x| x.into_tcx(tcx)).collect(),
modifier: from_trait_bound_modifier(modifier),
}
fn from_tcx(ty: clean::Type, tcx: TyCtxt<'_>) -> Self {
use clean::Type::*;
match ty {
- ResolvedPath { path, did, is_generic: _ } => Type::ResolvedPath {
+ ResolvedPath { path, did } => Type::ResolvedPath {
name: path.whole_name(),
id: from_item_id(did.into()),
args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))),
param_names: Vec::new(),
},
DynTrait(mut bounds, lt) => {
- let (path, id) = match bounds.remove(0).trait_ {
- ResolvedPath { path, did, .. } => (path, did),
- _ => unreachable!(),
- };
+ let first_trait = bounds.remove(0).trait_;
Type::ResolvedPath {
- name: path.whole_name(),
- id: from_item_id(id.into()),
- args: path
+ name: first_trait.whole_name(),
+ id: from_item_id(first_trait.res.def_id().into()),
+ args: first_trait
.segments
.last()
.map(|args| Box::new(args.clone().args.into_tcx(tcx))),
}
}
Generic(s) => Type::Generic(s.to_string()),
+ Primitive(clean::PrimitiveType::Never) => Type::Never,
Primitive(p) => Type::Primitive(p.as_sym().to_string()),
BareFunction(f) => Type::FunctionPointer(Box::new((*f).into_tcx(tcx))),
Tuple(t) => Type::Tuple(t.into_iter().map(|x| x.into_tcx(tcx)).collect()),
Slice(t) => Type::Slice(Box::new((*t).into_tcx(tcx))),
Array(t, s) => Type::Array { type_: Box::new((*t).into_tcx(tcx)), len: s },
ImplTrait(g) => Type::ImplTrait(g.into_iter().map(|x| x.into_tcx(tcx)).collect()),
- Never => Type::Never,
Infer => Type::Infer,
RawPointer(mutability, type_) => Type::RawPointer {
mutable: mutability == ast::Mutability::Mut,
mutable: mutability == ast::Mutability::Mut,
type_: Box::new((*type_).into_tcx(tcx)),
},
- QPath { name, self_type, trait_, .. } => Type::QualifiedPath {
- name: name.to_string(),
- self_type: Box::new((*self_type).into_tcx(tcx)),
- trait_: Box::new((*trait_).into_tcx(tcx)),
- },
+ QPath { name, self_type, trait_, .. } => {
+ // FIXME: should `trait_` be a clean::Path equivalent in JSON?
+ let trait_ = ResolvedPath { did: trait_.res.def_id(), path: *trait_ }.into_tcx(tcx);
+ Type::QualifiedPath {
+ name: name.to_string(),
+ self_type: Box::new((*self_type).into_tcx(tcx)),
+ trait_: Box::new(trait_),
+ }
+ }
}
}
}
blanket_impl,
span: _span,
} = impl_;
+ // FIXME: should `trait_` be a clean::Path equivalent in JSON?
+ let trait_ = trait_.map(|path| {
+ let did = path.res.def_id();
+ clean::ResolvedPath { path, did }.into_tcx(tcx)
+ });
Impl {
is_unsafe: unsafety == rustc_hir::Unsafety::Unsafe,
generics: generics.into_tcx(tcx),
.into_iter()
.map(|x| x.to_string())
.collect(),
- trait_: trait_.map(|x| x.into_tcx(tcx)),
+ trait_,
for_: for_.into_tcx(tcx),
items: ids(items),
negative: negative_polarity,
use clean::Variant::*;
match variant {
CLike => Variant::Plain,
- Tuple(t) => Variant::Tuple(t.into_iter().map(|x| x.into_tcx(tcx)).collect()),
+ Tuple(fields) => Variant::Tuple(
+ fields
+ .into_iter()
+ .map(|f| {
+ if let clean::StructFieldItem(ty) = *f.kind {
+ ty.into_tcx(tcx)
+ } else {
+ unreachable!()
+ }
+ })
+ .collect(),
+ ),
Struct(s) => Variant::Struct(ids(s.fields)),
}
}