Skip to content

Commit

Permalink
Unrolled build for rust-lang#123830
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rust-timer committed Apr 12, 2024
2 parents 7bdae13 + 9bcc988 commit f07acfc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/convert/num.rs
Expand Up @@ -165,8 +165,8 @@ impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);

// float -> float
impl_from!(f16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(f16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
// FIXME(f16_f128): adding additional `From` impls for existing types breaks inference. See
// <https://github.com/rust-lang/rust/issues/123824>
impl_from!(f16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(f32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(f32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/inference/untyped-primitives.rs
@@ -0,0 +1,9 @@
//@ check-pass
// issue: rust-lang/rust#123824
// This test is a sanity check and does not enforce any stable API, so may be
// removed at a future point.

fn main() {
let x = f32::from(3.14);
let y = f64::from(3.14);
}

0 comments on commit f07acfc

Please sign in to comment.