Skip to content

Commit bcf24d6

Browse files
authored
Rollup merge of rust-lang#123830 - tgross35:f16-f128-from-inference-fix, r=Nilstrieb
Remove `From` impls for unstable types that break inference Adding additional `From` implementations that fit `f32::from(<unaffixed float>)` broke inference. Remove these for now. I added a test to make sure this doesn't quietly change in the future, even though the behavior is not technically guaranteed rust-lang#123824 (comment) Fixes: <rust-lang#123824>
2 parents b467edd + 9bcc988 commit bcf24d6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: library/core/src/convert/num.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
165165
impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
166166

167167
// float -> float
168-
impl_from!(f16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
169-
impl_from!(f16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
168+
// FIXME(f16_f128): adding additional `From` impls for existing types breaks inference. See
169+
// <https://github.com/rust-lang/rust/issues/123824>
170170
impl_from!(f16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
171171
impl_from!(f32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
172172
impl_from!(f32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

Diff for: tests/ui/inference/untyped-primitives.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ check-pass
2+
// issue: rust-lang/rust#123824
3+
// This test is a sanity check and does not enforce any stable API, so may be
4+
// removed at a future point.
5+
6+
fn main() {
7+
let x = f32::from(3.14);
8+
let y = f64::from(3.14);
9+
}

0 commit comments

Comments
 (0)