diff --git a/chalk-integration/src/lowering.rs b/chalk-integration/src/lowering.rs index 530afdd66ae..ce6101b3a96 100644 --- a/chalk-integration/src/lowering.rs +++ b/chalk-integration/src/lowering.rs @@ -1206,8 +1206,10 @@ impl Lower for FloatTy { fn lower(&self) -> Self::Lowered { match self { + FloatTy::F16 => chalk_ir::FloatTy::F16, FloatTy::F32 => chalk_ir::FloatTy::F32, FloatTy::F64 => chalk_ir::FloatTy::F64, + FloatTy::F128 => chalk_ir::FloatTy::F128, } } } diff --git a/chalk-ir/src/lib.rs b/chalk-ir/src/lib.rs index 4a765673afc..c3096d9f672 100644 --- a/chalk-ir/src/lib.rs +++ b/chalk-ir/src/lib.rs @@ -265,8 +265,10 @@ pub enum UintTy { #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[allow(missing_docs)] pub enum FloatTy { + F16, F32, F64, + F128, } /// Types of scalar values. diff --git a/chalk-parse/src/ast.rs b/chalk-parse/src/ast.rs index d86ca9b5115..95c3a7da915 100644 --- a/chalk-parse/src/ast.rs +++ b/chalk-parse/src/ast.rs @@ -358,8 +358,10 @@ pub enum UintTy { #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum FloatTy { + F16, F32, F64, + F128, } #[derive(Copy, Clone, PartialEq, Eq, Debug)] diff --git a/chalk-parse/src/parser.lalrpop b/chalk-parse/src/parser.lalrpop index e037e6dc606..9979e8cfdc7 100644 --- a/chalk-parse/src/parser.lalrpop +++ b/chalk-parse/src/parser.lalrpop @@ -463,8 +463,10 @@ UintTy: UintTy = { }; FloatTy: FloatTy = { + "f16" => FloatTy::F16, "f32" => FloatTy::F32, "f64" => FloatTy::F64, + "f128" => FloatTy::F128, }; ScalarType: ScalarType = { diff --git a/chalk-solve/src/display/ty.rs b/chalk-solve/src/display/ty.rs index a00be4d8719..daa47ccc999 100644 --- a/chalk-solve/src/display/ty.rs +++ b/chalk-solve/src/display/ty.rs @@ -223,8 +223,10 @@ impl RenderAsRust for Scalar { U128 => "u128", }, Scalar::Float(float) => match float { + F16 => "f16", F32 => "f32", F64 => "f64", + F128 => "f128", }, } ) diff --git a/tests/display/built_ins.rs b/tests/display/built_ins.rs index 4c8184f6626..2026f72b155 100644 --- a/tests/display/built_ins.rs +++ b/tests/display/built_ins.rs @@ -34,7 +34,7 @@ fn test_scalar_types() { // words, test the matrix of {every scalar} x {concrete type usages}. This // test should be updated to include new scalars, but it isn't super // important that it includes every place a concrete type can be used. - let basic = &["bool", "char", "f32", "f64"]; + let basic = &["bool", "char", "f16", "f32", "f64", "f128"]; let ints = { let prefixes = &["u", "i"]; let sizes = &["size", "8", "16", "32", "64", "128"]; diff --git a/tests/lowering/mod.rs b/tests/lowering/mod.rs index 0a74b297132..628f7b2104e 100644 --- a/tests/lowering/mod.rs +++ b/tests/lowering/mod.rs @@ -490,8 +490,10 @@ fn scalars() { impl Foo for u64 { } impl Foo for u128 { } impl Foo for usize { } + impl Foo for f16 { } impl Foo for f32 { } impl Foo for f64 { } + impl Foo for f128 { } impl Foo for bool { } impl Foo for char { } } diff --git a/tests/test/scalars.rs b/tests/test/scalars.rs index 3513c158924..bdf265af7d6 100644 --- a/tests/test/scalars.rs +++ b/tests/test/scalars.rs @@ -62,8 +62,10 @@ fn scalar_trait_impl() { impl Foo for u64 { } impl Foo for u128 { } impl Foo for usize { } + impl Foo for f16 { } impl Foo for f32 { } impl Foo for f64 { } + impl Foo for f128 { } impl Foo for bool { } impl Foo for char { } @@ -88,8 +90,10 @@ fn scalar_trait_impl() { goal { u64: Foo } yields { expect![["Unique"]] } goal { u128: Foo } yields { expect![["Unique"]] } goal { usize: Foo } yields { expect![["Unique"]] } + goal { f16: Foo } yields { expect![["Unique"]] } goal { f32: Foo } yields { expect![["Unique"]] } goal { f64: Foo } yields { expect![["Unique"]] } + goal { f128: Foo } yields { expect![["Unique"]] } goal { bool: Foo } yields { expect![["Unique"]] } goal { char: Foo } yields { expect![["Unique"]] } @@ -105,8 +109,10 @@ fn scalar_trait_impl() { goal { u64: UnsignedFoo } yields { expect![["Unique"]] } goal { u128: UnsignedFoo } yields { expect![["Unique"]] } goal { usize: UnsignedFoo } yields { expect![["Unique"]] } + goal { f16: UnsignedFoo } yields { expect![["No possible solution"]] } goal { f32: UnsignedFoo } yields { expect![["No possible solution"]] } goal { f64: UnsignedFoo } yields { expect![["No possible solution"]] } + goal { f128: UnsignedFoo } yields { expect![["No possible solution"]] } goal { bool: UnsignedFoo } yields { expect![["No possible solution"]] } goal { char: UnsignedFoo } yields { expect![["No possible solution"]] } @@ -128,8 +134,10 @@ fn scalars_are_well_formed() { goal { WellFormed(u64) } yields { expect![["Unique"]] } goal { WellFormed(u128) } yields { expect![["Unique"]] } goal { WellFormed(usize) } yields { expect![["Unique"]] } + goal { WellFormed(f16) } yields { expect![["Unique"]] } goal { WellFormed(f32) } yields { expect![["Unique"]] } goal { WellFormed(f64) } yields { expect![["Unique"]] } + goal { WellFormed(f128) } yields { expect![["Unique"]] } goal { WellFormed(bool) } yields { expect![["Unique"]] } goal { WellFormed(char) } yields { expect![["Unique"]] } } @@ -154,8 +162,10 @@ fn scalars_are_sized() { goal { u64: Sized } yields { expect![["Unique"]] } goal { u128: Sized } yields { expect![["Unique"]] } goal { usize: Sized } yields { expect![["Unique"]] } + goal { f16: Sized } yields { expect![["Unique"]] } goal { f32: Sized } yields { expect![["Unique"]] } goal { f64: Sized } yields { expect![["Unique"]] } + goal { f128: Sized } yields { expect![["Unique"]] } goal { bool: Sized } yields { expect![["Unique"]] } goal { char: Sized } yields { expect![["Unique"]] } }