diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-12 13:35:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-12 13:35:30 +0200 |
| commit | bcf24d6467018f1f718e0dcd44155abaa8acfbac (patch) | |
| tree | efcc556766d707193b9bce1c4059e7fe7746ab8f | |
| parent | b467eddf64c1fa1237945e46bdb7ed47811a9535 (diff) | |
| parent | 9bcc98818c9b59dd0106aed95c4349c2c8ecdc48 (diff) | |
| download | rust-bcf24d6467018f1f718e0dcd44155abaa8acfbac.tar.gz rust-bcf24d6467018f1f718e0dcd44155abaa8acfbac.zip | |
Rollup merge of #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 https://github.com/rust-lang/rust/issues/123824#issuecomment-2050628184 Fixes: <https://github.com/rust-lang/rust/issues/123824>
| -rw-r--r-- | library/core/src/convert/num.rs | 4 | ||||
| -rw-r--r-- | tests/ui/inference/untyped-primitives.rs | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs index 1737c631f0b..935ead2699a 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs @@ -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")]); diff --git a/tests/ui/inference/untyped-primitives.rs b/tests/ui/inference/untyped-primitives.rs new file mode 100644 index 00000000000..8515ca79903 --- /dev/null +++ b/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); +} |
