mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Stop reexporting PrimitiveType
enum in librustdoc.
This commit is contained in:
parent
0c9ff54139
commit
9dde563990
@ -12,7 +12,6 @@
|
|||||||
//! that clean them.
|
//! that clean them.
|
||||||
|
|
||||||
pub use self::Type::*;
|
pub use self::Type::*;
|
||||||
pub use self::PrimitiveType::*;
|
|
||||||
pub use self::TypeKind::*;
|
pub use self::TypeKind::*;
|
||||||
pub use self::VariantKind::*;
|
pub use self::VariantKind::*;
|
||||||
pub use self::Mutability::*;
|
pub use self::Mutability::*;
|
||||||
@ -1517,12 +1516,12 @@ impl Type {
|
|||||||
pub fn primitive_type(&self) -> Option<PrimitiveType> {
|
pub fn primitive_type(&self) -> Option<PrimitiveType> {
|
||||||
match *self {
|
match *self {
|
||||||
Primitive(p) | BorrowedRef { type_: box Primitive(p), ..} => Some(p),
|
Primitive(p) | BorrowedRef { type_: box Primitive(p), ..} => Some(p),
|
||||||
Vector(..) | BorrowedRef{ type_: box Vector(..), .. } => Some(Slice),
|
Vector(..) | BorrowedRef{ type_: box Vector(..), .. } => Some(PrimitiveType::Slice),
|
||||||
FixedVector(..) | BorrowedRef { type_: box FixedVector(..), .. } => {
|
FixedVector(..) | BorrowedRef { type_: box FixedVector(..), .. } => {
|
||||||
Some(Array)
|
Some(PrimitiveType::Array)
|
||||||
}
|
}
|
||||||
Tuple(..) => Some(PrimitiveTuple),
|
Tuple(..) => Some(PrimitiveType::PrimitiveTuple),
|
||||||
RawPointer(..) => Some(PrimitiveRawPointer),
|
RawPointer(..) => Some(PrimitiveType::PrimitiveRawPointer),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1547,25 +1546,25 @@ impl GetDefId for Type {
|
|||||||
impl PrimitiveType {
|
impl PrimitiveType {
|
||||||
fn from_str(s: &str) -> Option<PrimitiveType> {
|
fn from_str(s: &str) -> Option<PrimitiveType> {
|
||||||
match s {
|
match s {
|
||||||
"isize" => Some(Isize),
|
"isize" => Some(PrimitiveType::Isize),
|
||||||
"i8" => Some(I8),
|
"i8" => Some(PrimitiveType::I8),
|
||||||
"i16" => Some(I16),
|
"i16" => Some(PrimitiveType::I16),
|
||||||
"i32" => Some(I32),
|
"i32" => Some(PrimitiveType::I32),
|
||||||
"i64" => Some(I64),
|
"i64" => Some(PrimitiveType::I64),
|
||||||
"usize" => Some(Usize),
|
"usize" => Some(PrimitiveType::Usize),
|
||||||
"u8" => Some(U8),
|
"u8" => Some(PrimitiveType::U8),
|
||||||
"u16" => Some(U16),
|
"u16" => Some(PrimitiveType::U16),
|
||||||
"u32" => Some(U32),
|
"u32" => Some(PrimitiveType::U32),
|
||||||
"u64" => Some(U64),
|
"u64" => Some(PrimitiveType::U64),
|
||||||
"bool" => Some(Bool),
|
"bool" => Some(PrimitiveType::Bool),
|
||||||
"char" => Some(Char),
|
"char" => Some(PrimitiveType::Char),
|
||||||
"str" => Some(Str),
|
"str" => Some(PrimitiveType::Str),
|
||||||
"f32" => Some(F32),
|
"f32" => Some(PrimitiveType::F32),
|
||||||
"f64" => Some(F64),
|
"f64" => Some(PrimitiveType::F64),
|
||||||
"array" => Some(Array),
|
"array" => Some(PrimitiveType::Array),
|
||||||
"slice" => Some(Slice),
|
"slice" => Some(PrimitiveType::Slice),
|
||||||
"tuple" => Some(PrimitiveTuple),
|
"tuple" => Some(PrimitiveType::PrimitiveTuple),
|
||||||
"pointer" => Some(PrimitiveRawPointer),
|
"pointer" => Some(PrimitiveType::PrimitiveRawPointer),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1585,25 +1584,25 @@ impl PrimitiveType {
|
|||||||
|
|
||||||
pub fn to_string(&self) -> &'static str {
|
pub fn to_string(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
Isize => "isize",
|
PrimitiveType::Isize => "isize",
|
||||||
I8 => "i8",
|
PrimitiveType::I8 => "i8",
|
||||||
I16 => "i16",
|
PrimitiveType::I16 => "i16",
|
||||||
I32 => "i32",
|
PrimitiveType::I32 => "i32",
|
||||||
I64 => "i64",
|
PrimitiveType::I64 => "i64",
|
||||||
Usize => "usize",
|
PrimitiveType::Usize => "usize",
|
||||||
U8 => "u8",
|
PrimitiveType::U8 => "u8",
|
||||||
U16 => "u16",
|
PrimitiveType::U16 => "u16",
|
||||||
U32 => "u32",
|
PrimitiveType::U32 => "u32",
|
||||||
U64 => "u64",
|
PrimitiveType::U64 => "u64",
|
||||||
F32 => "f32",
|
PrimitiveType::F32 => "f32",
|
||||||
F64 => "f64",
|
PrimitiveType::F64 => "f64",
|
||||||
Str => "str",
|
PrimitiveType::Str => "str",
|
||||||
Bool => "bool",
|
PrimitiveType::Bool => "bool",
|
||||||
Char => "char",
|
PrimitiveType::Char => "char",
|
||||||
Array => "array",
|
PrimitiveType::Array => "array",
|
||||||
Slice => "slice",
|
PrimitiveType::Slice => "slice",
|
||||||
PrimitiveTuple => "tuple",
|
PrimitiveType::PrimitiveTuple => "tuple",
|
||||||
PrimitiveRawPointer => "pointer",
|
PrimitiveType::PrimitiveRawPointer => "pointer",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1771,21 +1770,21 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
|
|||||||
fn clean(&self, cx: &DocContext) -> Type {
|
fn clean(&self, cx: &DocContext) -> Type {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
ty::TyNever => Never,
|
ty::TyNever => Never,
|
||||||
ty::TyBool => Primitive(Bool),
|
ty::TyBool => Primitive(PrimitiveType::Bool),
|
||||||
ty::TyChar => Primitive(Char),
|
ty::TyChar => Primitive(PrimitiveType::Char),
|
||||||
ty::TyInt(ast::IntTy::Is) => Primitive(Isize),
|
ty::TyInt(ast::IntTy::Is) => Primitive(PrimitiveType::Isize),
|
||||||
ty::TyInt(ast::IntTy::I8) => Primitive(I8),
|
ty::TyInt(ast::IntTy::I8) => Primitive(PrimitiveType::I8),
|
||||||
ty::TyInt(ast::IntTy::I16) => Primitive(I16),
|
ty::TyInt(ast::IntTy::I16) => Primitive(PrimitiveType::I16),
|
||||||
ty::TyInt(ast::IntTy::I32) => Primitive(I32),
|
ty::TyInt(ast::IntTy::I32) => Primitive(PrimitiveType::I32),
|
||||||
ty::TyInt(ast::IntTy::I64) => Primitive(I64),
|
ty::TyInt(ast::IntTy::I64) => Primitive(PrimitiveType::I64),
|
||||||
ty::TyUint(ast::UintTy::Us) => Primitive(Usize),
|
ty::TyUint(ast::UintTy::Us) => Primitive(PrimitiveType::Usize),
|
||||||
ty::TyUint(ast::UintTy::U8) => Primitive(U8),
|
ty::TyUint(ast::UintTy::U8) => Primitive(PrimitiveType::U8),
|
||||||
ty::TyUint(ast::UintTy::U16) => Primitive(U16),
|
ty::TyUint(ast::UintTy::U16) => Primitive(PrimitiveType::U16),
|
||||||
ty::TyUint(ast::UintTy::U32) => Primitive(U32),
|
ty::TyUint(ast::UintTy::U32) => Primitive(PrimitiveType::U32),
|
||||||
ty::TyUint(ast::UintTy::U64) => Primitive(U64),
|
ty::TyUint(ast::UintTy::U64) => Primitive(PrimitiveType::U64),
|
||||||
ty::TyFloat(ast::FloatTy::F32) => Primitive(F32),
|
ty::TyFloat(ast::FloatTy::F32) => Primitive(PrimitiveType::F32),
|
||||||
ty::TyFloat(ast::FloatTy::F64) => Primitive(F64),
|
ty::TyFloat(ast::FloatTy::F64) => Primitive(PrimitiveType::F64),
|
||||||
ty::TyStr => Primitive(Str),
|
ty::TyStr => Primitive(PrimitiveType::Str),
|
||||||
ty::TyBox(t) => {
|
ty::TyBox(t) => {
|
||||||
let box_did = cx.tcx_opt().and_then(|tcx| {
|
let box_did = cx.tcx_opt().and_then(|tcx| {
|
||||||
tcx.lang_items.owned_box()
|
tcx.lang_items.owned_box()
|
||||||
@ -2438,25 +2437,25 @@ fn build_deref_target_impls(cx: &DocContext,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let did = match primitive {
|
let did = match primitive {
|
||||||
Isize => tcx.lang_items.isize_impl(),
|
PrimitiveType::Isize => tcx.lang_items.isize_impl(),
|
||||||
I8 => tcx.lang_items.i8_impl(),
|
PrimitiveType::I8 => tcx.lang_items.i8_impl(),
|
||||||
I16 => tcx.lang_items.i16_impl(),
|
PrimitiveType::I16 => tcx.lang_items.i16_impl(),
|
||||||
I32 => tcx.lang_items.i32_impl(),
|
PrimitiveType::I32 => tcx.lang_items.i32_impl(),
|
||||||
I64 => tcx.lang_items.i64_impl(),
|
PrimitiveType::I64 => tcx.lang_items.i64_impl(),
|
||||||
Usize => tcx.lang_items.usize_impl(),
|
PrimitiveType::Usize => tcx.lang_items.usize_impl(),
|
||||||
U8 => tcx.lang_items.u8_impl(),
|
PrimitiveType::U8 => tcx.lang_items.u8_impl(),
|
||||||
U16 => tcx.lang_items.u16_impl(),
|
PrimitiveType::U16 => tcx.lang_items.u16_impl(),
|
||||||
U32 => tcx.lang_items.u32_impl(),
|
PrimitiveType::U32 => tcx.lang_items.u32_impl(),
|
||||||
U64 => tcx.lang_items.u64_impl(),
|
PrimitiveType::U64 => tcx.lang_items.u64_impl(),
|
||||||
F32 => tcx.lang_items.f32_impl(),
|
PrimitiveType::F32 => tcx.lang_items.f32_impl(),
|
||||||
F64 => tcx.lang_items.f64_impl(),
|
PrimitiveType::F64 => tcx.lang_items.f64_impl(),
|
||||||
Char => tcx.lang_items.char_impl(),
|
PrimitiveType::Char => tcx.lang_items.char_impl(),
|
||||||
Bool => None,
|
PrimitiveType::Bool => None,
|
||||||
Str => tcx.lang_items.str_impl(),
|
PrimitiveType::Str => tcx.lang_items.str_impl(),
|
||||||
Slice => tcx.lang_items.slice_impl(),
|
PrimitiveType::Slice => tcx.lang_items.slice_impl(),
|
||||||
Array => tcx.lang_items.slice_impl(),
|
PrimitiveType::Array => tcx.lang_items.slice_impl(),
|
||||||
PrimitiveTuple => None,
|
PrimitiveType::PrimitiveTuple => None,
|
||||||
PrimitiveRawPointer => tcx.lang_items.const_ptr_impl(),
|
PrimitiveType::PrimitiveRawPointer => tcx.lang_items.const_ptr_impl(),
|
||||||
};
|
};
|
||||||
if let Some(did) = did {
|
if let Some(did) = did {
|
||||||
if !did.is_local() {
|
if !did.is_local() {
|
||||||
@ -2739,21 +2738,21 @@ fn resolve_type(cx: &DocContext,
|
|||||||
|
|
||||||
let is_generic = match def {
|
let is_generic = match def {
|
||||||
Def::PrimTy(p) => match p {
|
Def::PrimTy(p) => match p {
|
||||||
hir::TyStr => return Primitive(Str),
|
hir::TyStr => return Primitive(PrimitiveType::Str),
|
||||||
hir::TyBool => return Primitive(Bool),
|
hir::TyBool => return Primitive(PrimitiveType::Bool),
|
||||||
hir::TyChar => return Primitive(Char),
|
hir::TyChar => return Primitive(PrimitiveType::Char),
|
||||||
hir::TyInt(ast::IntTy::Is) => return Primitive(Isize),
|
hir::TyInt(ast::IntTy::Is) => return Primitive(PrimitiveType::Isize),
|
||||||
hir::TyInt(ast::IntTy::I8) => return Primitive(I8),
|
hir::TyInt(ast::IntTy::I8) => return Primitive(PrimitiveType::I8),
|
||||||
hir::TyInt(ast::IntTy::I16) => return Primitive(I16),
|
hir::TyInt(ast::IntTy::I16) => return Primitive(PrimitiveType::I16),
|
||||||
hir::TyInt(ast::IntTy::I32) => return Primitive(I32),
|
hir::TyInt(ast::IntTy::I32) => return Primitive(PrimitiveType::I32),
|
||||||
hir::TyInt(ast::IntTy::I64) => return Primitive(I64),
|
hir::TyInt(ast::IntTy::I64) => return Primitive(PrimitiveType::I64),
|
||||||
hir::TyUint(ast::UintTy::Us) => return Primitive(Usize),
|
hir::TyUint(ast::UintTy::Us) => return Primitive(PrimitiveType::Usize),
|
||||||
hir::TyUint(ast::UintTy::U8) => return Primitive(U8),
|
hir::TyUint(ast::UintTy::U8) => return Primitive(PrimitiveType::U8),
|
||||||
hir::TyUint(ast::UintTy::U16) => return Primitive(U16),
|
hir::TyUint(ast::UintTy::U16) => return Primitive(PrimitiveType::U16),
|
||||||
hir::TyUint(ast::UintTy::U32) => return Primitive(U32),
|
hir::TyUint(ast::UintTy::U32) => return Primitive(PrimitiveType::U32),
|
||||||
hir::TyUint(ast::UintTy::U64) => return Primitive(U64),
|
hir::TyUint(ast::UintTy::U64) => return Primitive(PrimitiveType::U64),
|
||||||
hir::TyFloat(ast::FloatTy::F32) => return Primitive(F32),
|
hir::TyFloat(ast::FloatTy::F32) => return Primitive(PrimitiveType::F32),
|
||||||
hir::TyFloat(ast::FloatTy::F64) => return Primitive(F64),
|
hir::TyFloat(ast::FloatTy::F64) => return Primitive(PrimitiveType::F64),
|
||||||
},
|
},
|
||||||
Def::SelfTy(..) if path.segments.len() == 1 => {
|
Def::SelfTy(..) if path.segments.len() == 1 => {
|
||||||
return Generic(keywords::SelfType.name().to_string());
|
return Generic(keywords::SelfType.name().to_string());
|
||||||
|
@ -23,7 +23,7 @@ use rustc::hir::def_id::DefId;
|
|||||||
use syntax::abi::Abi;
|
use syntax::abi::Abi;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
|
||||||
use clean;
|
use clean::{self, PrimitiveType};
|
||||||
use core::DocAccessLevels;
|
use core::DocAccessLevels;
|
||||||
use html::item_type::ItemType;
|
use html::item_type::ItemType;
|
||||||
use html::escape::Escape;
|
use html::escape::Escape;
|
||||||
@ -468,28 +468,28 @@ impl fmt::Display for clean::Type {
|
|||||||
}
|
}
|
||||||
clean::Tuple(ref typs) => {
|
clean::Tuple(ref typs) => {
|
||||||
match &typs[..] {
|
match &typs[..] {
|
||||||
&[] => primitive_link(f, clean::PrimitiveTuple, "()"),
|
&[] => primitive_link(f, PrimitiveType::PrimitiveTuple, "()"),
|
||||||
&[ref one] => {
|
&[ref one] => {
|
||||||
primitive_link(f, clean::PrimitiveTuple, "(")?;
|
primitive_link(f, PrimitiveType::PrimitiveTuple, "(")?;
|
||||||
write!(f, "{},", one)?;
|
write!(f, "{},", one)?;
|
||||||
primitive_link(f, clean::PrimitiveTuple, ")")
|
primitive_link(f, PrimitiveType::PrimitiveTuple, ")")
|
||||||
}
|
}
|
||||||
many => {
|
many => {
|
||||||
primitive_link(f, clean::PrimitiveTuple, "(")?;
|
primitive_link(f, PrimitiveType::PrimitiveTuple, "(")?;
|
||||||
write!(f, "{}", CommaSep(&many))?;
|
write!(f, "{}", CommaSep(&many))?;
|
||||||
primitive_link(f, clean::PrimitiveTuple, ")")
|
primitive_link(f, PrimitiveType::PrimitiveTuple, ")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::Vector(ref t) => {
|
clean::Vector(ref t) => {
|
||||||
primitive_link(f, clean::Slice, &format!("["))?;
|
primitive_link(f, PrimitiveType::Slice, &format!("["))?;
|
||||||
write!(f, "{}", t)?;
|
write!(f, "{}", t)?;
|
||||||
primitive_link(f, clean::Slice, &format!("]"))
|
primitive_link(f, PrimitiveType::Slice, &format!("]"))
|
||||||
}
|
}
|
||||||
clean::FixedVector(ref t, ref s) => {
|
clean::FixedVector(ref t, ref s) => {
|
||||||
primitive_link(f, clean::PrimitiveType::Array, "[")?;
|
primitive_link(f, PrimitiveType::Array, "[")?;
|
||||||
write!(f, "{}", t)?;
|
write!(f, "{}", t)?;
|
||||||
primitive_link(f, clean::PrimitiveType::Array,
|
primitive_link(f, PrimitiveType::Array,
|
||||||
&format!("; {}]", Escape(s)))
|
&format!("; {}]", Escape(s)))
|
||||||
}
|
}
|
||||||
clean::Never => f.write_str("!"),
|
clean::Never => f.write_str("!"),
|
||||||
@ -516,12 +516,13 @@ impl fmt::Display for clean::Type {
|
|||||||
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
|
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
|
||||||
match **bt {
|
match **bt {
|
||||||
clean::Generic(_) =>
|
clean::Generic(_) =>
|
||||||
primitive_link(f, clean::Slice,
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
&format!("&{}{}[{}]", lt, m, **bt)),
|
&format!("&{}{}[{}]", lt, m, **bt)),
|
||||||
_ => {
|
_ => {
|
||||||
primitive_link(f, clean::Slice, &format!("&{}{}[", lt, m))?;
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
|
&format!("&{}{}[", lt, m))?;
|
||||||
write!(f, "{}", **bt)?;
|
write!(f, "{}", **bt)?;
|
||||||
primitive_link(f, clean::Slice, "]")
|
primitive_link(f, PrimitiveType::Slice, "]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user