Skip to content

Commit 5da1a1b

Browse files
committed
Auto merge of #123085 - tgross35:f16-f128-step4.0-libs-basic-impls, r=Amanieu
Add basic trait impls for `f16` and `f128` Split off part of <#122470> so the compiler doesn't ICE because it expects primitives to have some minimal traits. Fixes <#123074>
2 parents 8df7e72 + d7d5fc9 commit 5da1a1b

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

library/core/src/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ mod impls {
227227
impl_clone! {
228228
usize u8 u16 u32 u64 u128
229229
isize i8 i16 i32 i64 i128
230-
f32 f64
230+
f16 f32 f64 f128
231231
bool char
232232
}
233233

library/core/src/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ mod impls {
14931493
}
14941494

14951495
partial_eq_impl! {
1496-
bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64
1496+
bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
14971497
}
14981498

14991499
macro_rules! eq_impl {
@@ -1546,7 +1546,7 @@ mod impls {
15461546
}
15471547
}
15481548

1549-
partial_ord_impl! { f32 f64 }
1549+
partial_ord_impl! { f16 f32 f64 f128 }
15501550

15511551
macro_rules! ord_impl {
15521552
($($t:ty)*) => ($(

library/core/src/default.rs

+4
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,9 @@ default_impl! { i32, 0, "Returns the default value of `0`" }
178178
default_impl! { i64, 0, "Returns the default value of `0`" }
179179
default_impl! { i128, 0, "Returns the default value of `0`" }
180180

181+
#[cfg(not(bootstrap))]
182+
default_impl! { f16, 0.0f16, "Returns the default value of `0.0`" }
181183
default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" }
182184
default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" }
185+
#[cfg(not(bootstrap))]
186+
default_impl! { f128, 0.0f128, "Returns the default value of `0.0`" }

library/core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@
229229
#![feature(doc_notable_trait)]
230230
#![feature(effects)]
231231
#![feature(extern_types)]
232+
#![feature(f128)]
233+
#![feature(f16)]
232234
#![feature(freeze_impls)]
233235
#![feature(fundamental)]
234236
#![feature(generic_arg_infer)]

library/core/src/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ marker_impls! {
422422
Copy for
423423
usize, u8, u16, u32, u64, u128,
424424
isize, i8, i16, i32, i64, i128,
425-
f32, f64,
425+
f16, f32, f64, f128,
426426
bool, char,
427427
{T: ?Sized} *const T,
428428
{T: ?Sized} *mut T,

tests/ui/binop/binary-op-suggest-deref.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ LL | _ = &&0 == Foo;
247247
|
248248
= help: the trait `PartialEq<Foo>` is not implemented for `&&{integer}`
249249
= help: the following other types implement trait `PartialEq<Rhs>`:
250+
f128
251+
f16
250252
f32
251253
f64
252254
i128
253255
i16
254256
i32
255257
i64
256-
i8
257-
isize
258-
and 6 others
258+
and 8 others
259259

260260
error[E0369]: binary operation `==` cannot be applied to type `Foo`
261261
--> $DIR/binary-op-suggest-deref.rs:60:13

tests/ui/mismatched_types/binops.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ LL | 5 < String::new();
7373
|
7474
= help: the trait `PartialOrd<String>` is not implemented for `{integer}`
7575
= help: the following other types implement trait `PartialOrd<Rhs>`:
76+
f128
77+
f16
7678
f32
7779
f64
7880
i128
7981
i16
8082
i32
8183
i64
82-
i8
83-
isize
84-
and 6 others
84+
and 8 others
8585

8686
error[E0277]: can't compare `{integer}` with `Result<{integer}, _>`
8787
--> $DIR/binops.rs:7:7
@@ -91,15 +91,15 @@ LL | 6 == Ok(1);
9191
|
9292
= help: the trait `PartialEq<Result<{integer}, _>>` is not implemented for `{integer}`
9393
= help: the following other types implement trait `PartialEq<Rhs>`:
94+
f128
95+
f16
9496
f32
9597
f64
9698
i128
9799
i16
98100
i32
99101
i64
100-
i8
101-
isize
102-
and 6 others
102+
and 8 others
103103

104104
error: aborting due to 6 previous errors
105105

0 commit comments

Comments
 (0)