Skip to content

Commit

Permalink
Add stubs for f16 and f128 to clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Feb 28, 2024
1 parent 7be6e21 commit 17930c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clippy_lints/src/float_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
LitFloatType::Unsuffixed => None,
};
let (is_whole, is_inf, mut float_str) = match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => {
let value = sym_str.parse::<f32>().unwrap();

Expand All @@ -91,6 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {

(value.fract() == 0.0, value.is_infinite(), formatter.format(value))
},
FloatTy::F128 => unimplemented!("f16_f128"),
};

if is_inf {
Expand Down Expand Up @@ -135,8 +137,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
#[must_use]
fn max_digits(fty: FloatTy) -> u32 {
match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => f32::DIGITS,
FloatTy::F64 => f64::DIGITS,
FloatTy::F128 => unimplemented!("f16_f128"),
}
}

Expand Down
2 changes: 2 additions & 0 deletions clippy_utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,10 @@ pub fn mir_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::Const<'tcx>) ->
let range = alloc_range(offset + size * idx, size);
let val = alloc.read_scalar(&lcx.tcx, range, /* read_provenance */ false).ok()?;
res.push(match flt {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)),
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)),
FloatTy::F128 => unimplemented!("f16_f128"),
});
}
Some(Constant::Vec(res))
Expand Down

0 comments on commit 17930c9

Please sign in to comment.