Skip to content

Commit 2ccb1a1

Browse files
authored
Rollup merge of #124797 - beetrees:primitive-float, r=davidtwco
Refactor float `Primitive`s to a separate `Float` type Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`. As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2 parents 643e56d + 861cca5 commit 2ccb1a1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/hir-ty/src/layout.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use base_db::salsa::Cycle;
66
use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy};
77
use hir_def::{
88
layout::{
9-
Abi, FieldsShape, Integer, LayoutCalculator, LayoutS, Primitive, ReprOptions, Scalar, Size,
10-
StructKind, TargetDataLayout, WrappingRange,
9+
Abi, FieldsShape, Float, Integer, LayoutCalculator, LayoutS, Primitive, ReprOptions,
10+
Scalar, Size, StructKind, TargetDataLayout, WrappingRange,
1111
},
1212
LocalFieldId, StructId,
1313
};
@@ -264,10 +264,10 @@ pub fn layout_of_ty_query(
264264
),
265265
chalk_ir::Scalar::Float(f) => scalar(
266266
dl,
267-
match f {
268-
FloatTy::F32 => Primitive::F32,
269-
FloatTy::F64 => Primitive::F64,
270-
},
267+
Primitive::Float(match f {
268+
FloatTy::F32 => Float::F32,
269+
FloatTy::F64 => Float::F64,
270+
}),
271271
),
272272
},
273273
TyKind::Tuple(len, tys) => {

0 commit comments

Comments
 (0)