about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-08-23 19:22:18 -0400
committerCorey Farwell <coreyf@rwell.org>2016-08-24 23:27:25 -0700
commit168cfea8afaf2dddae3d848a7f49ecb63d130b47 (patch)
tree68758f261715b62ae5b1128693c969021de8ecce
parent8a6f7a5ced0217344f2f8a8c6a98aefb08b10fa7 (diff)
downloadrust-168cfea8afaf2dddae3d848a7f49ecb63d130b47.tar.gz
rust-168cfea8afaf2dddae3d848a7f49ecb63d130b47.zip
Implement `From<ast::UintTy>` for `PrimitiveType`.
-rw-r--r--src/librustdoc/clean/mod.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 3abc7e98536..4f455e7d073 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -1631,6 +1631,18 @@ impl From<ast::IntTy> for PrimitiveType {
     }
 }
 
+impl From<ast::UintTy> for PrimitiveType {
+    fn from(uint_ty: ast::UintTy) -> PrimitiveType {
+        match uint_ty {
+            ast::UintTy::Us => PrimitiveType::Usize,
+            ast::UintTy::U8 => PrimitiveType::U8,
+            ast::UintTy::U16 => PrimitiveType::U16,
+            ast::UintTy::U32 => PrimitiveType::U32,
+            ast::UintTy::U64 => PrimitiveType::U64,
+        }
+    }
+}
+
 // Poor man's type parameter substitution at HIR level.
 // Used to replace private type aliases in public signatures with their aliased types.
 struct SubstAlias<'a, 'tcx: 'a> {
@@ -1784,11 +1796,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
             ty::TyBool => Primitive(PrimitiveType::Bool),
             ty::TyChar => Primitive(PrimitiveType::Char),
             ty::TyInt(int_ty) => Primitive(int_ty.into()),
-            ty::TyUint(ast::UintTy::Us) => Primitive(PrimitiveType::Usize),
-            ty::TyUint(ast::UintTy::U8) => Primitive(PrimitiveType::U8),
-            ty::TyUint(ast::UintTy::U16) => Primitive(PrimitiveType::U16),
-            ty::TyUint(ast::UintTy::U32) => Primitive(PrimitiveType::U32),
-            ty::TyUint(ast::UintTy::U64) => Primitive(PrimitiveType::U64),
+            ty::TyUint(uint_ty) => Primitive(uint_ty.into()),
             ty::TyFloat(ast::FloatTy::F32) => Primitive(PrimitiveType::F32),
             ty::TyFloat(ast::FloatTy::F64) => Primitive(PrimitiveType::F64),
             ty::TyStr => Primitive(PrimitiveType::Str),
@@ -2749,11 +2757,7 @@ fn resolve_type(cx: &DocContext,
             hir::TyBool => return Primitive(PrimitiveType::Bool),
             hir::TyChar => return Primitive(PrimitiveType::Char),
             hir::TyInt(int_ty) => return Primitive(int_ty.into()),
-            hir::TyUint(ast::UintTy::Us) => return Primitive(PrimitiveType::Usize),
-            hir::TyUint(ast::UintTy::U8) => return Primitive(PrimitiveType::U8),
-            hir::TyUint(ast::UintTy::U16) => return Primitive(PrimitiveType::U16),
-            hir::TyUint(ast::UintTy::U32) => return Primitive(PrimitiveType::U32),
-            hir::TyUint(ast::UintTy::U64) => return Primitive(PrimitiveType::U64),
+            hir::TyUint(uint_ty) => return Primitive(uint_ty.into()),
             hir::TyFloat(ast::FloatTy::F32) => return Primitive(PrimitiveType::F32),
             hir::TyFloat(ast::FloatTy::F64) => return Primitive(PrimitiveType::F64),
         },