Add basic trait impls for f16 and f128

Split off part of <https://github.com/rust-lang/rust/pull/122470> so the
compiler doesn't ICE because it expects primitives to have some minimal
traits.

Fixes <https://github.com/rust-lang/rust/issues/123074>
This commit is contained in:
Trevor Gross 2024-03-26 05:22:18 -04:00
parent c5e7f45b62
commit d7d5fc9734
7 changed files with 19 additions and 13 deletions

View File

@ -227,7 +227,7 @@ fn clone(&self) -> Self {
impl_clone! {
usize u8 u16 u32 u64 u128
isize i8 i16 i32 i64 i128
f32 f64
f16 f32 f64 f128
bool char
}

View File

@ -1486,7 +1486,7 @@ fn ne(&self, _other: &()) -> bool {
}
partial_eq_impl! {
bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64
bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
}
macro_rules! eq_impl {
@ -1539,7 +1539,7 @@ fn partial_cmp(&self, other: &bool) -> Option<Ordering> {
}
}
partial_ord_impl! { f32 f64 }
partial_ord_impl! { f16 f32 f64 f128 }
macro_rules! ord_impl {
($($t:ty)*) => ($(

View File

@ -178,5 +178,9 @@ fn default() -> $t {
default_impl! { i64, 0, "Returns the default value of `0`" }
default_impl! { i128, 0, "Returns the default value of `0`" }
#[cfg(not(bootstrap))]
default_impl! { f16, 0.0f16, "Returns the default value of `0.0`" }
default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" }
default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" }
#[cfg(not(bootstrap))]
default_impl! { f128, 0.0f128, "Returns the default value of `0.0`" }

View File

@ -229,6 +229,8 @@
#![feature(doc_notable_trait)]
#![feature(effects)]
#![feature(extern_types)]
#![feature(f128)]
#![feature(f16)]
#![feature(freeze_impls)]
#![feature(fundamental)]
#![feature(generic_arg_infer)]

View File

@ -422,7 +422,7 @@ pub trait Copy: Clone {
Copy for
usize, u8, u16, u32, u64, u128,
isize, i8, i16, i32, i64, i128,
f32, f64,
f16, f32, f64, f128,
bool, char,
{T: ?Sized} *const T,
{T: ?Sized} *mut T,

View File

@ -247,15 +247,15 @@ LL | _ = &&0 == Foo;
|
= help: the trait `PartialEq<Foo>` is not implemented for `&&{integer}`
= help: the following other types implement trait `PartialEq<Rhs>`:
f128
f16
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others
and 8 others
error[E0369]: binary operation `==` cannot be applied to type `Foo`
--> $DIR/binary-op-suggest-deref.rs:60:13

View File

@ -73,15 +73,15 @@ LL | 5 < String::new();
|
= help: the trait `PartialOrd<String>` is not implemented for `{integer}`
= help: the following other types implement trait `PartialOrd<Rhs>`:
f128
f16
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others
and 8 others
error[E0277]: can't compare `{integer}` with `Result<{integer}, _>`
--> $DIR/binops.rs:7:7
@ -91,15 +91,15 @@ LL | 6 == Ok(1);
|
= help: the trait `PartialEq<Result<{integer}, _>>` is not implemented for `{integer}`
= help: the following other types implement trait `PartialEq<Rhs>`:
f128
f16
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others
and 8 others
error: aborting due to 6 previous errors