Skip to content

Commit

Permalink
Add basic trait impls for f16 and f128
Browse files Browse the repository at this point in the history
Split off part of <#122470> so the
compiler doesn't ICE because it expects primitives to have some minimal
traits.

Fixes <#123074>
  • Loading branch information
tgross35 committed Mar 27, 2024
1 parent a1b4991 commit cd1e659
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library/core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ mod impls {
impl_clone! {
usize u8 u16 u32 u64 u128
isize i8 i16 i32 i64 i128
f32 f64
f16 f32 f64 f128
bool char
}

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ mod impls {
}

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 {
Expand Down Expand Up @@ -1539,7 +1539,7 @@ mod impls {
}
}

partial_ord_impl! { f32 f64 }
partial_ord_impl! { f16 f32 f64 f128 }

macro_rules! ord_impl {
($($t:ty)*) => ($(
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,7 @@ default_impl! { i32, 0, "Returns the default value of `0`" }
default_impl! { i64, 0, "Returns the default value of `0`" }
default_impl! { i128, 0, "Returns the default value of `0`" }

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`" }
default_impl! { f128, 0.0f128, "Returns the default value of `0.0`" }
2 changes: 2 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ marker_impls! {
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,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/binop/binary-op-suggest-deref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ LL | _ = &&0 == Foo;
i128
usize
u8
and 6 others
and 8 others

error[E0369]: binary operation `==` cannot be applied to type `Foo`
--> $DIR/binary-op-suggest-deref.rs:60:13
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/mismatched_types/binops.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ LL | 5 < String::new();
i128
usize
u8
and 6 others
and 8 others

error[E0277]: can't compare `{integer}` with `Result<{integer}, _>`
--> $DIR/binops.rs:7:7
Expand All @@ -99,7 +99,7 @@ LL | 6 == Ok(1);
i128
usize
u8
and 6 others
and 8 others

error: aborting due to 6 previous errors

Expand Down

0 comments on commit cd1e659

Please sign in to comment.