Skip to content

Commit 3c2318c

Browse files
committed
make remaining FloatTy matches exhaustive
1 parent a5a8437 commit 3c2318c

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/tools/miri/src/helpers.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -1102,20 +1102,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
11021102
}
11031103
}
11041104

1105-
let (val, status) = match src.layout.ty.kind() {
1106-
// f32
1107-
ty::Float(FloatTy::F32) =>
1105+
let ty::Float(fty) = src.layout.ty.kind() else {
1106+
bug!("float_to_int_checked: non-float input type {}", src.layout.ty)
1107+
};
1108+
1109+
let (val, status) = match fty {
1110+
FloatTy::F16 => unimplemented!("f16_f128"),
1111+
FloatTy::F32 =>
11081112
float_to_int_inner::<Single>(this, src.to_scalar().to_f32()?, cast_to, round),
1109-
// f64
1110-
ty::Float(FloatTy::F64) =>
1113+
FloatTy::F64 =>
11111114
float_to_int_inner::<Double>(this, src.to_scalar().to_f64()?, cast_to, round),
1112-
// Nothing else
1113-
_ =>
1114-
span_bug!(
1115-
this.cur_span(),
1116-
"attempted float-to-int conversion with non-float input type {}",
1117-
src.layout.ty,
1118-
),
1115+
FloatTy::F128 => unimplemented!("f16_f128"),
11191116
};
11201117

11211118
if status.intersects(

src/tools/miri/src/shims/intrinsics/mod.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
274274
_ => bug!(),
275275
};
276276
let float_finite = |x: &ImmTy<'tcx, _>| -> InterpResult<'tcx, bool> {
277-
Ok(match x.layout.ty.kind() {
278-
ty::Float(FloatTy::F32) => x.to_scalar().to_f32()?.is_finite(),
279-
ty::Float(FloatTy::F64) => x.to_scalar().to_f64()?.is_finite(),
280-
_ => bug!(
281-
"`{intrinsic_name}` called with non-float input type {ty:?}",
282-
ty = x.layout.ty,
283-
),
277+
let ty::Float(fty) = x.layout.ty.kind() else {
278+
bug!("float_finite: non-float input type {}", x.layout.ty)
279+
};
280+
Ok(match fty {
281+
FloatTy::F16 => unimplemented!("f16_f128"),
282+
FloatTy::F32 => x.to_scalar().to_f32()?.is_finite(),
283+
FloatTy::F64 => x.to_scalar().to_f64()?.is_finite(),
284+
FloatTy::F128 => unimplemented!("f16_f128"),
284285
})
285286
};
286287
match (float_finite(&a)?, float_finite(&b)?) {

0 commit comments

Comments
 (0)