Skip to content

Commit

Permalink
Enable f16 and f128 in HIR
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Mar 14, 2024
1 parent 80bb15e commit dc65095
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2444,7 +2444,7 @@ pub enum PrimTy {

impl PrimTy {
/// All of the primitive types
pub const ALL: [Self; 17] = [
pub const ALL: [Self; 19] = [
// any changes here should also be reflected in `PrimTy::from_name`
Self::Int(IntTy::I8),
Self::Int(IntTy::I16),
Expand All @@ -2458,9 +2458,10 @@ impl PrimTy {
Self::Uint(UintTy::U64),
Self::Uint(UintTy::U128),
Self::Uint(UintTy::Usize),
Self::Float(FloatTy::F16),
Self::Float(FloatTy::F32),
Self::Float(FloatTy::F64),
// FIXME(f16_f128): add these when enabled below
Self::Float(FloatTy::F128),
Self::Bool,
Self::Char,
Self::Str,
Expand Down Expand Up @@ -2508,12 +2509,10 @@ impl PrimTy {
sym::u64 => Self::Uint(UintTy::U64),
sym::u128 => Self::Uint(UintTy::U128),
sym::usize => Self::Uint(UintTy::Usize),
sym::f16 => Self::Float(FloatTy::F16),
sym::f32 => Self::Float(FloatTy::F32),
sym::f64 => Self::Float(FloatTy::F64),
// FIXME(f16_f128): enabling these will open the gates of f16 and f128 being
// understood by rustc.
// sym::f16 => Self::Float(FloatTy::F16),
// sym::f128 => Self::Float(FloatTy::F128),
sym::f128 => Self::Float(FloatTy::F128),
sym::bool => Self::Bool,
sym::char => Self::Char,
sym::str => Self::Str,
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,11 @@ fn lint_literal<'tcx>(
ty::Float(t) => {
let is_infinite = match lit.node {
ast::LitKind::Float(v, _) => match t {
ty::FloatTy::F16 => unimplemented!("f16_f128"),
// FIXME(f16_f128): add this check once we have library support
ty::FloatTy::F16 => Ok(false),
ty::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite),
ty::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite),
ty::FloatTy::F128 => unimplemented!("f16_f128"),
ty::FloatTy::F128 => Ok(false),
},
_ => bug!(),
};
Expand Down

0 comments on commit dc65095

Please sign in to comment.