Skip to content

Commit fb18033

Browse files
committed
Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errors
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in rust-lang/rust#114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in rust-lang/rust#120645 (comment)
2 parents 14b7251 + 17930c9 commit fb18033

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

clippy_lints/src/float_literal.rs

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
8181
LitFloatType::Unsuffixed => None,
8282
};
8383
let (is_whole, is_inf, mut float_str) = match fty {
84+
FloatTy::F16 => unimplemented!("f16_f128"),
8485
FloatTy::F32 => {
8586
let value = sym_str.parse::<f32>().unwrap();
8687

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

9293
(value.fract() == 0.0, value.is_infinite(), formatter.format(value))
9394
},
95+
FloatTy::F128 => unimplemented!("f16_f128"),
9496
};
9597

9698
if is_inf {
@@ -135,8 +137,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
135137
#[must_use]
136138
fn max_digits(fty: FloatTy) -> u32 {
137139
match fty {
140+
FloatTy::F16 => unimplemented!("f16_f128"),
138141
FloatTy::F32 => f32::DIGITS,
139142
FloatTy::F64 => f64::DIGITS,
143+
FloatTy::F128 => unimplemented!("f16_f128"),
140144
}
141145
}
142146

clippy_utils/src/consts.rs

+2
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,10 @@ pub fn mir_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::Const<'tcx>) ->
778778
let range = alloc_range(offset + size * idx, size);
779779
let val = alloc.read_scalar(&lcx.tcx, range, /* read_provenance */ false).ok()?;
780780
res.push(match flt {
781+
FloatTy::F16 => unimplemented!("f16_f128"),
781782
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().ok()?)),
782783
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().ok()?)),
784+
FloatTy::F128 => unimplemented!("f16_f128"),
783785
});
784786
}
785787
Some(Constant::Vec(res))

0 commit comments

Comments
 (0)