提交 c3bc905e 编写于 作者: C Corey Farwell

Remove redundant 'Type' in variant names, stop reexporting.

上级 8991ffc3
......@@ -73,33 +73,33 @@ fn try_inline_def<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
let did = def.def_id();
let inner = match def {
Def::Trait(did) => {
record_extern_fqn(cx, did, clean::TypeTrait);
record_extern_fqn(cx, did, clean::TypeKind::Trait);
ret.extend(build_impls(cx, tcx, did));
clean::TraitItem(build_external_trait(cx, tcx, did))
}
Def::Fn(did) => {
record_extern_fqn(cx, did, clean::TypeFunction);
record_extern_fqn(cx, did, clean::TypeKind::Function);
clean::FunctionItem(build_external_function(cx, tcx, did))
}
Def::Struct(did)
// If this is a struct constructor, we skip it
if tcx.def_key(did).disambiguated_data.data != DefPathData::StructCtor => {
record_extern_fqn(cx, did, clean::TypeStruct);
record_extern_fqn(cx, did, clean::TypeKind::Struct);
ret.extend(build_impls(cx, tcx, did));
clean::StructItem(build_struct(cx, tcx, did))
}
Def::Union(did) => {
record_extern_fqn(cx, did, clean::TypeUnion);
record_extern_fqn(cx, did, clean::TypeKind::Union);
ret.extend(build_impls(cx, tcx, did));
clean::UnionItem(build_union(cx, tcx, did))
}
Def::TyAlias(did) => {
record_extern_fqn(cx, did, clean::TypeTypedef);
record_extern_fqn(cx, did, clean::TypeKind::Typedef);
ret.extend(build_impls(cx, tcx, did));
clean::TypedefItem(build_type_alias(cx, tcx, did), false)
}
Def::Enum(did) => {
record_extern_fqn(cx, did, clean::TypeEnum);
record_extern_fqn(cx, did, clean::TypeKind::Enum);
ret.extend(build_impls(cx, tcx, did));
clean::EnumItem(build_enum(cx, tcx, did))
}
......@@ -107,15 +107,15 @@ fn try_inline_def<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
// variants don't show up in documentation specially.
Def::Variant(..) => return Some(Vec::new()),
Def::Mod(did) => {
record_extern_fqn(cx, did, clean::TypeModule);
record_extern_fqn(cx, did, clean::TypeKind::Module);
clean::ModuleItem(build_module(cx, tcx, did))
}
Def::Static(did, mtbl) => {
record_extern_fqn(cx, did, clean::TypeStatic);
record_extern_fqn(cx, did, clean::TypeKind::Static);
clean::StaticItem(build_static(cx, tcx, did, mtbl))
}
Def::Const(did) | Def::AssociatedConst(did) => {
record_extern_fqn(cx, did, clean::TypeConst);
record_extern_fqn(cx, did, clean::TypeKind::Const);
clean::ConstantItem(build_const(cx, tcx, did))
}
_ => return None,
......
......@@ -12,7 +12,6 @@
//! that clean them.
pub use self::Type::*;
pub use self::TypeKind::*;
pub use self::VariantKind::*;
pub use self::Mutability::*;
pub use self::Import::*;
......@@ -688,7 +687,7 @@ fn clean(&self, cx: &DocContext) -> TyParamBound {
(tcx.lang_items.sync_trait().unwrap(),
external_path(cx, "Sync", None, false, vec![], empty)),
};
inline::record_extern_fqn(cx, did, TypeTrait);
inline::record_extern_fqn(cx, did, TypeKind::Trait);
TraitBound(PolyTrait {
trait_: ResolvedPath {
path: path,
......@@ -707,7 +706,7 @@ fn clean(&self, cx: &DocContext) -> TyParamBound {
Some(tcx) => tcx,
None => return RegionBound(Lifetime::statik())
};
inline::record_extern_fqn(cx, self.def_id, TypeTrait);
inline::record_extern_fqn(cx, self.def_id, TypeKind::Trait);
let path = external_path(cx, &tcx.item_name(self.def_id).as_str(),
Some(self.def_id), true, vec![], self.substs);
......@@ -1480,16 +1479,16 @@ pub enum PrimitiveType {
#[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
pub enum TypeKind {
TypeEnum,
TypeFunction,
TypeModule,
TypeConst,
TypeStatic,
TypeStruct,
TypeUnion,
TypeTrait,
TypeVariant,
TypeTypedef,
Enum,
Function,
Module,
Const,
Static,
Struct,
Union,
Trait,
Variant,
Typedef,
}
pub trait GetDefId {
......@@ -1795,9 +1794,9 @@ fn clean(&self, cx: &DocContext) -> Type {
ty::TyAdt(def, substs) => {
let did = def.did;
let kind = match def.adt_kind() {
AdtKind::Struct => TypeStruct,
AdtKind::Union => TypeUnion,
AdtKind::Enum => TypeEnum,
AdtKind::Struct => TypeKind::Struct,
AdtKind::Union => TypeKind::Union,
AdtKind::Enum => TypeKind::Enum,
};
inline::record_extern_fqn(cx, did, kind);
let path = external_path(cx, &cx.tcx().item_name(did).as_str(),
......@@ -1811,7 +1810,7 @@ fn clean(&self, cx: &DocContext) -> Type {
}
ty::TyTrait(ref obj) => {
let did = obj.principal.def_id();
inline::record_extern_fqn(cx, did, TypeTrait);
inline::record_extern_fqn(cx, did, TypeKind::Trait);
let mut typarams = vec![];
obj.region_bound.clean(cx).map(|b| typarams.push(RegionBound(b)));
......@@ -2761,16 +2760,16 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
let tcx = cx.tcx();
let (did, kind) = match def {
Def::Fn(i) => (i, TypeFunction),
Def::TyAlias(i) => (i, TypeTypedef),
Def::Enum(i) => (i, TypeEnum),
Def::Trait(i) => (i, TypeTrait),
Def::Struct(i) => (i, TypeStruct),
Def::Union(i) => (i, TypeUnion),
Def::Mod(i) => (i, TypeModule),
Def::Static(i, _) => (i, TypeStatic),
Def::Variant(i) => (tcx.parent_def_id(i).unwrap(), TypeEnum),
Def::SelfTy(Some(def_id), _) => (def_id, TypeTrait),
Def::Fn(i) => (i, TypeKind::Function),
Def::TyAlias(i) => (i, TypeKind::Typedef),
Def::Enum(i) => (i, TypeKind::Enum),
Def::Trait(i) => (i, TypeKind::Trait),
Def::Struct(i) => (i, TypeKind::Struct),
Def::Union(i) => (i, TypeKind::Union),
Def::Mod(i) => (i, TypeKind::Module),
Def::Static(i, _) => (i, TypeKind::Static),
Def::Variant(i) => (tcx.parent_def_id(i).unwrap(), TypeKind::Enum),
Def::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
Def::SelfTy(_, Some(impl_def_id)) => {
return impl_def_id
}
......@@ -2778,7 +2777,7 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
};
if did.is_local() { return did }
inline::record_extern_fqn(cx, did, kind);
if let TypeTrait = kind {
if let TypeKind::Trait = kind {
let t = inline::build_external_trait(cx, tcx, did);
cx.external_traits.borrow_mut().insert(did, t);
}
......@@ -2966,7 +2965,7 @@ fn lang_struct(cx: &DocContext, did: Option<DefId>,
Some(did) => did,
None => return fallback(box t.clean(cx)),
};
inline::record_extern_fqn(cx, did, TypeStruct);
inline::record_extern_fqn(cx, did, TypeKind::Struct);
ResolvedPath {
typarams: None,
did: did,
......
......@@ -90,16 +90,16 @@ fn from(item: &'a clean::Item) -> ItemType {
impl From<clean::TypeKind> for ItemType {
fn from(kind: clean::TypeKind) -> ItemType {
match kind {
clean::TypeStruct => ItemType::Struct,
clean::TypeUnion => ItemType::Union,
clean::TypeEnum => ItemType::Enum,
clean::TypeFunction => ItemType::Function,
clean::TypeTrait => ItemType::Trait,
clean::TypeModule => ItemType::Module,
clean::TypeStatic => ItemType::Static,
clean::TypeConst => ItemType::Constant,
clean::TypeVariant => ItemType::Variant,
clean::TypeTypedef => ItemType::Typedef,
clean::TypeKind::Struct => ItemType::Struct,
clean::TypeKind::Union => ItemType::Union,
clean::TypeKind::Enum => ItemType::Enum,
clean::TypeKind::Function => ItemType::Function,
clean::TypeKind::Trait => ItemType::Trait,
clean::TypeKind::Module => ItemType::Module,
clean::TypeKind::Static => ItemType::Static,
clean::TypeKind::Const => ItemType::Constant,
clean::TypeKind::Variant => ItemType::Variant,
clean::TypeKind::Typedef => ItemType::Typedef,
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册