Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change f16 and f128 clippy stubs to be nonpanicking #123087

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/tools/clippy/clippy_lints/src/float_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ 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::F16 => {
// FIXME(f16_f128): do a check like the others when parsing is available
return;
},
FloatTy::F32 => {
let value = sym_str.parse::<f32>().unwrap();

Expand All @@ -94,7 +97,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {

(value.fract() == 0.0, value.is_infinite(), formatter.format(value))
},
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => {
// FIXME(f16_f128): do a check like the others when parsing is available
return;
},
};

if is_inf {
Expand Down Expand Up @@ -139,10 +145,11 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
#[must_use]
fn max_digits(fty: FloatTy) -> u32 {
match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
// FIXME(f16_f128): replace the magic numbers once `{f16,f128}::DIGITS` are available
FloatTy::F16 => 3,
FloatTy::F32 => f32::DIGITS,
FloatTy::F64 => f64::DIGITS,
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => 33,
}
}

Expand Down
Loading