Skip to content

Commit dd17e21

Browse files
committed
Enable f16 and f128 in HIR
1 parent cb04cf1 commit dd17e21

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

compiler/rustc_hir/src/hir.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ pub enum PrimTy {
24442444

24452445
impl PrimTy {
24462446
/// All of the primitive types
2447-
pub const ALL: [Self; 17] = [
2447+
pub const ALL: [Self; 19] = [
24482448
// any changes here should also be reflected in `PrimTy::from_name`
24492449
Self::Int(IntTy::I8),
24502450
Self::Int(IntTy::I16),
@@ -2458,9 +2458,10 @@ impl PrimTy {
24582458
Self::Uint(UintTy::U64),
24592459
Self::Uint(UintTy::U128),
24602460
Self::Uint(UintTy::Usize),
2461+
Self::Float(FloatTy::F16),
24612462
Self::Float(FloatTy::F32),
24622463
Self::Float(FloatTy::F64),
2463-
// FIXME(f16_f128): add these when enabled below
2464+
Self::Float(FloatTy::F128),
24642465
Self::Bool,
24652466
Self::Char,
24662467
Self::Str,
@@ -2508,12 +2509,10 @@ impl PrimTy {
25082509
sym::u64 => Self::Uint(UintTy::U64),
25092510
sym::u128 => Self::Uint(UintTy::U128),
25102511
sym::usize => Self::Uint(UintTy::Usize),
2512+
sym::f16 => Self::Float(FloatTy::F16),
25112513
sym::f32 => Self::Float(FloatTy::F32),
25122514
sym::f64 => Self::Float(FloatTy::F64),
2513-
// FIXME(f16_f128): enabling these will open the gates of f16 and f128 being
2514-
// understood by rustc.
2515-
// sym::f16 => Self::Float(FloatTy::F16),
2516-
// sym::f128 => Self::Float(FloatTy::F128),
2515+
sym::f128 => Self::Float(FloatTy::F128),
25172516
sym::bool => Self::Bool,
25182517
sym::char => Self::Char,
25192518
sym::str => Self::Str,

compiler/rustc_lint/src/types.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,11 @@ fn lint_literal<'tcx>(
561561
ty::Float(t) => {
562562
let is_infinite = match lit.node {
563563
ast::LitKind::Float(v, _) => match t {
564-
ty::FloatTy::F16 => unimplemented!("f16_f128"),
564+
// FIXME(f16_f128): add this check once we have library support
565+
ty::FloatTy::F16 => Ok(false),
565566
ty::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite),
566567
ty::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite),
567-
ty::FloatTy::F128 => unimplemented!("f16_f128"),
568+
ty::FloatTy::F128 => Ok(false),
568569
},
569570
_ => bug!(),
570571
};

0 commit comments

Comments
 (0)