pub mod types;
pub mod utils;
-use rustc::hir;
-use rustc::hir::def::{CtorKind, DefKind, Res};
-use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
-use rustc::hir::ptr::P;
use rustc::infer::region_constraints::{Constraint, RegionConstraintData};
use rustc::middle::lang_items;
use rustc::middle::resolve_lifetime as rl;
use rustc::ty::fold::TypeFolder;
use rustc::ty::subst::InternalSubsts;
use rustc::ty::{self, AdtKind, Lift, Ty, TyCtxt};
-use rustc::util::nodemap::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_hir as hir;
+use rustc_hir::def::{CtorKind, DefKind, Res};
+use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
use rustc_index::vec::{Idx, IndexVec};
+use rustc_mir::const_eval::is_min_const_fn;
+use rustc_span::hygiene::MacroKind;
+use rustc_span::symbol::{kw, sym};
+use rustc_span::{self, Pos};
use rustc_typeck::hir_ty_to_ty;
use syntax::ast::{self, Ident};
use syntax::attr;
-use syntax_pos::hygiene::MacroKind;
-use syntax_pos::symbol::{kw, sym};
-use syntax_pos::{self, Pos};
use std::collections::hash_map::Entry;
use std::default::Default;
}
}
-impl<T: Clean<U>, U> Clean<U> for P<T> {
- fn clean(&self, cx: &DocContext<'_>) -> U {
- (**self).clean(cx)
- }
-}
-
impl<T: Clean<U>, U> Clean<U> for Rc<T> {
fn clean(&self, cx: &DocContext<'_>) -> U {
(**self).clean(cx)
}
}
-impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
- fn clean(&self, cx: &DocContext<'_>) -> Vec<U> {
- self.iter().map(|x| x.clean(cx)).collect()
- }
-}
-
impl Clean<ExternalCrate> for CrateNum {
fn clean(&self, cx: &DocContext<'_>) -> ExternalCrate {
let root = DefId { krate: *self, index: CRATE_DEF_INDEX };
}
}
-impl Clean<GenericBound> for hir::GenericBound {
+impl Clean<GenericBound> for hir::GenericBound<'_> {
fn clean(&self, cx: &DocContext<'_>) -> GenericBound {
match *self {
hir::GenericBound::Outlives(lt) => GenericBound::Outlives(lt.clean(cx)),
}
}
-impl Clean<Lifetime> for hir::GenericParam {
+impl Clean<Lifetime> for hir::GenericParam<'_> {
fn clean(&self, _: &DocContext<'_>) -> Lifetime {
match self.kind {
hir::GenericParamKind::Lifetime { .. } => {
}
}
-impl Clean<WherePredicate> for hir::WherePredicate {
+impl Clean<WherePredicate> for hir::WherePredicate<'_> {
fn clean(&self, cx: &DocContext<'_>) -> WherePredicate {
match *self {
hir::WherePredicate::BoundPredicate(ref wbp) => WherePredicate::BoundPredicate {
}
}
-impl Clean<GenericParamDef> for hir::GenericParam {
+impl Clean<GenericParamDef> for hir::GenericParam<'_> {
fn clean(&self, cx: &DocContext<'_>) -> GenericParamDef {
let (name, kind) = match self.kind {
hir::GenericParamKind::Lifetime { .. } => {
}
}
-impl Clean<Generics> for hir::Generics {
+impl Clean<Generics> for hir::Generics<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Generics {
// Synthetic type-parameters are inserted after normal ones.
// In order for normal parameters to be able to refer to synthetic ones,
// scans them first.
- fn is_impl_trait(param: &hir::GenericParam) -> bool {
+ fn is_impl_trait(param: &hir::GenericParam<'_>) -> bool {
match param.kind {
hir::GenericParamKind::Type { synthetic, .. } => {
synthetic == Some(hir::SyntheticTyParamKind::ImplTrait)
}
impl<'a> Clean<Method>
- for (&'a hir::FnSig, &'a hir::Generics, hir::BodyId, Option<hir::Defaultness>)
+ for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::BodyId, Option<hir::Defaultness>)
{
fn clean(&self, cx: &DocContext<'_>) -> Method {
let (generics, decl) =
enter_impl_trait(cx, || (self.generics.clean(cx), (self.decl, self.body).clean(cx)));
let did = cx.tcx.hir().local_def_id(self.id);
- let constness = if cx.tcx.is_min_const_fn(did) {
+ let constness = if is_min_const_fn(cx.tcx, did) {
hir::Constness::Const
} else {
hir::Constness::NotConst
}
}
-impl<'a> Clean<Arguments> for (&'a [hir::Ty], &'a [ast::Ident]) {
+impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], &'a [ast::Ident]) {
fn clean(&self, cx: &DocContext<'_>) -> Arguments {
Arguments {
values: self
}
}
-impl<'a> Clean<Arguments> for (&'a [hir::Ty], hir::BodyId) {
+impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
fn clean(&self, cx: &DocContext<'_>) -> Arguments {
let body = cx.tcx.hir().body(self.1);
}
}
-impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl, A)
+impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl<'a>, A)
where
- (&'a [hir::Ty], A): Clean<Arguments>,
+ (&'a [hir::Ty<'a>], A): Clean<Arguments>,
{
fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
FnDecl {
}
}
-impl Clean<FunctionRetTy> for hir::FunctionRetTy {
+impl Clean<FunctionRetTy> for hir::FunctionRetTy<'_> {
fn clean(&self, cx: &DocContext<'_>) -> FunctionRetTy {
match *self {
- hir::Return(ref typ) => Return(typ.clean(cx)),
- hir::DefaultReturn(..) => DefaultReturn,
+ Self::Return(ref typ) => Return(typ.clean(cx)),
+ Self::DefaultReturn(..) => DefaultReturn,
}
}
}
}
}
-impl Clean<Type> for hir::TraitRef {
+impl Clean<Type> for hir::TraitRef<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Type {
resolve_type(cx, self.path.clean(cx), self.hir_ref_id)
}
}
-impl Clean<PolyTrait> for hir::PolyTraitRef {
+impl Clean<PolyTrait> for hir::PolyTraitRef<'_> {
fn clean(&self, cx: &DocContext<'_>) -> PolyTrait {
PolyTrait {
trait_: self.trait_ref.clean(cx),
MethodItem((sig, &self.generics, body, Some(self.defaultness)).clean(cx))
}
hir::ImplItemKind::TyAlias(ref ty) => {
- TypedefItem(Typedef { type_: ty.clean(cx), generics: Generics::default() }, true)
+ let type_ = ty.clean(cx);
+ let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
+ TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true)
}
hir::ImplItemKind::OpaqueTy(ref bounds) => OpaqueTyItem(
OpaqueTy { bounds: bounds.clean(cx), generics: Generics::default() },
};
let (all_types, ret_types) = get_all_types(&generics, &decl, cx);
if provided {
- let constness = if cx.tcx.is_min_const_fn(self.def_id) {
+ let constness = if is_min_const_fn(cx.tcx, self.def_id) {
hir::Constness::Const
} else {
hir::Constness::NotConst
AssocTypeItem(bounds, ty.clean(cx))
} else {
+ let type_ = cx.tcx.type_of(self.def_id).clean(cx);
+ let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
TypedefItem(
Typedef {
- type_: cx.tcx.type_of(self.def_id).clean(cx),
+ type_,
generics: Generics { params: Vec::new(), where_predicates: Vec::new() },
+ item_type,
},
true,
)
}
}
-impl Clean<Type> for hir::Ty {
+impl Clean<Type> for hir::Ty<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Type {
- use rustc::hir::*;
+ use rustc_hir::*;
match self.kind {
TyKind::Never => Never,
if let ty::Projection(proj) = ty.kind {
res = Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id);
}
- let trait_path = hir::Path { span: self.span, res, segments: vec![].into() };
+ let trait_path = hir::Path { span: self.span, res, segments: &[] };
Type::QPath {
name: segment.ident.name.clean(cx),
self_type: box qself.clean(cx),
}
}
-impl Clean<Visibility> for hir::Visibility {
+impl Clean<Visibility> for hir::Visibility<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Visibility {
match self.node {
hir::VisibilityKind::Public => Visibility::Public,
}
}
-impl Clean<VariantStruct> for ::rustc::hir::VariantData<'_> {
+impl Clean<VariantStruct> for rustc_hir::VariantData<'_> {
fn clean(&self, cx: &DocContext<'_>) -> VariantStruct {
VariantStruct {
struct_type: doctree::struct_type_from_def(self),
}
}
-impl Clean<Span> for syntax_pos::Span {
+impl Clean<Span> for rustc_span::Span {
fn clean(&self, cx: &DocContext<'_>) -> Span {
if self.is_dummy() {
return Span::empty();
}
}
-impl Clean<Path> for hir::Path {
+impl Clean<Path> for hir::Path<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Path {
Path {
global: self.is_global(),
}
}
-impl Clean<GenericArgs> for hir::GenericArgs {
+impl Clean<GenericArgs> for hir::GenericArgs<'_> {
fn clean(&self, cx: &DocContext<'_>) -> GenericArgs {
if self.parenthesized {
let output = self.bindings[0].ty().clean(cx);
}
}
-impl Clean<PathSegment> for hir::PathSegment {
+impl Clean<PathSegment> for hir::PathSegment<'_> {
fn clean(&self, cx: &DocContext<'_>) -> PathSegment {
PathSegment { name: self.ident.name.clean(cx), args: self.generic_args().clean(cx) }
}
impl Clean<Item> for doctree::Typedef<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Item {
+ let type_ = self.ty.clean(cx);
+ let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
Item {
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
visibility: self.vis.clean(cx),
stability: cx.stability(self.id).clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
- inner: TypedefItem(
- Typedef { type_: self.ty.clean(cx), generics: self.gen.clean(cx) },
- false,
- ),
+ inner: TypedefItem(Typedef { type_, generics: self.gen.clean(cx), item_type }, false),
}
}
}
}
}
-impl Clean<BareFunctionDecl> for hir::BareFnTy {
+impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
fn clean(&self, cx: &DocContext<'_>) -> BareFunctionDecl {
let (generic_params, decl) = enter_impl_trait(cx, || {
(self.generic_params.clean(cx), (&*self.decl, &self.param_names[..]).clean(cx))
build_deref_target_impls(cx, &items, &mut ret);
}
- let provided = trait_
+ let provided: FxHashSet<String> = trait_
.def_id()
.map(|did| {
cx.tcx
})
.unwrap_or_default();
- ret.push(Item {
+ let for_ = self.for_.clean(cx);
+ let type_alias = for_.def_id().and_then(|did| match cx.tcx.def_kind(did) {
+ Some(DefKind::TyAlias) => Some(cx.tcx.type_of(did).clean(cx)),
+ _ => None,
+ });
+ let make_item = |trait_: Option<Type>, for_: Type, items: Vec<Item>| Item {
name: None,
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
inner: ImplItem(Impl {
unsafety: self.unsafety,
generics: self.generics.clean(cx),
- provided_trait_methods: provided,
+ provided_trait_methods: provided.clone(),
trait_,
- for_: self.for_.clean(cx),
+ for_,
items,
polarity: Some(cx.tcx.impl_polarity(def_id).clean(cx)),
synthetic: false,
blanket_impl: None,
}),
- });
+ };
+ if let Some(type_alias) = type_alias {
+ ret.push(make_item(trait_.clone(), type_alias, items.clone()));
+ }
+ ret.push(make_item(trait_, for_, items));
ret
}
}
}
}
-impl Clean<TypeBinding> for hir::TypeBinding {
+impl Clean<TypeBinding> for hir::TypeBinding<'_> {
fn clean(&self, cx: &DocContext<'_>) -> TypeBinding {
TypeBinding { name: self.ident.name.clean(cx), kind: self.kind.clean(cx) }
}
}
-impl Clean<TypeBindingKind> for hir::TypeBindingKind {
+impl Clean<TypeBindingKind> for hir::TypeBindingKind<'_> {
fn clean(&self, cx: &DocContext<'_>) -> TypeBindingKind {
match *self {
hir::TypeBindingKind::Equality { ref ty } => {