Skip to content

Commit 42e8ac8

Browse files
committed
Implement From<ast::FloatTy> for PrimitiveType.
1 parent 168cfea commit 42e8ac8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,15 @@ impl From<ast::UintTy> for PrimitiveType {
16431643
}
16441644
}
16451645

1646+
impl From<ast::FloatTy> for PrimitiveType {
1647+
fn from(float_ty: ast::FloatTy) -> PrimitiveType {
1648+
match float_ty {
1649+
ast::FloatTy::F32 => PrimitiveType::F32,
1650+
ast::FloatTy::F64 => PrimitiveType::F64,
1651+
}
1652+
}
1653+
}
1654+
16461655
// Poor man's type parameter substitution at HIR level.
16471656
// Used to replace private type aliases in public signatures with their aliased types.
16481657
struct SubstAlias<'a, 'tcx: 'a> {
@@ -1797,8 +1806,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
17971806
ty::TyChar => Primitive(PrimitiveType::Char),
17981807
ty::TyInt(int_ty) => Primitive(int_ty.into()),
17991808
ty::TyUint(uint_ty) => Primitive(uint_ty.into()),
1800-
ty::TyFloat(ast::FloatTy::F32) => Primitive(PrimitiveType::F32),
1801-
ty::TyFloat(ast::FloatTy::F64) => Primitive(PrimitiveType::F64),
1809+
ty::TyFloat(float_ty) => Primitive(float_ty.into()),
18021810
ty::TyStr => Primitive(PrimitiveType::Str),
18031811
ty::TyBox(t) => {
18041812
let box_did = cx.tcx_opt().and_then(|tcx| {
@@ -2758,8 +2766,7 @@ fn resolve_type(cx: &DocContext,
27582766
hir::TyChar => return Primitive(PrimitiveType::Char),
27592767
hir::TyInt(int_ty) => return Primitive(int_ty.into()),
27602768
hir::TyUint(uint_ty) => return Primitive(uint_ty.into()),
2761-
hir::TyFloat(ast::FloatTy::F32) => return Primitive(PrimitiveType::F32),
2762-
hir::TyFloat(ast::FloatTy::F64) => return Primitive(PrimitiveType::F64),
2769+
hir::TyFloat(float_ty) => return Primitive(float_ty.into()),
27632770
},
27642771
Def::SelfTy(..) if path.segments.len() == 1 => {
27652772
return Generic(keywords::SelfType.name().to_string());

0 commit comments

Comments
 (0)