diff --git a/library/core/src/convert/num.rs b/library/core/src/convert/num.rs index 40d61de50aaf2..b80980219b1e2 100644 --- a/library/core/src/convert/num.rs +++ b/library/core/src/convert/num.rs @@ -70,8 +70,8 @@ impl_from_bool!(i8 i16 i32 i64 i128 isize); /// Implement `From<$small>` for `$large` macro_rules! impl_from { - ($small:ty => $large:ty, #[$attr:meta]) => { - #[$attr] + ($small:ty => $large:ty, $(#[$attrs:meta]),+) => { + $(#[$attrs])+ #[rustc_const_unstable(feature = "const_convert", issue = "143773")] impl const From<$small> for $large { #[doc = concat!("Converts from [`", stringify!($small), "`] to [`", stringify!($large), "`] losslessly.")] @@ -157,8 +157,7 @@ impl_from!(i16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0" impl_from!(i16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(i32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(i32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); -// FIXME(f128): This impl would allow using `f128` on stable before it is stabilised. -// impl_from!(i64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); +impl_from!(i64 => f128, #[unstable(feature = "f128", issue = "116909")], #[unstable_feature_bound(f128)]); // unsigned integer -> float impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); @@ -170,8 +169,7 @@ impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0" impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u32 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); impl_from!(u32 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); -// FIXME(f128): This impl would allow using `f128` on stable before it is stabilised. -// impl_from!(u64 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]); +impl_from!(u64 => f128, #[unstable(feature = "f128", issue = "116909")], #[unstable_feature_bound(f128)]); // float -> float // FIXME(f16,f128): adding additional `From<{float}>` impls to `f32` breaks inference. See diff --git a/tests/ui/feature-gates/feature-gate-f128.e2015.stderr b/tests/ui/feature-gates/feature-gate-f128.e2015.stderr index 7e8ea5e948dca..627010a935475 100644 --- a/tests/ui/feature-gates/feature-gate-f128.e2015.stderr +++ b/tests/ui/feature-gates/feature-gate-f128.e2015.stderr @@ -19,7 +19,27 @@ LL | let a: f128 = 100.0; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the type `f128` is unstable - --> $DIR/feature-gate-f128.rs:16:11 + --> $DIR/feature-gate-f128.rs:13:12 + | +LL | let d: f128 = 1i64.into(); + | ^^^^ + | + = note: see issue #116909 for more information + = help: add `#![feature(f128)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the type `f128` is unstable + --> $DIR/feature-gate-f128.rs:16:12 + | +LL | let e: f128 = 1u64.into(); + | ^^^^ + | + = note: see issue #116909 for more information + = help: add `#![feature(f128)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the type `f128` is unstable + --> $DIR/feature-gate-f128.rs:21:11 | LL | fn foo(a: f128) {} | ^^^^ @@ -29,7 +49,7 @@ LL | fn foo(a: f128) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the type `f128` is unstable - --> $DIR/feature-gate-f128.rs:19:8 + --> $DIR/feature-gate-f128.rs:24:8 | LL | a: f128, | ^^^^ @@ -58,6 +78,17 @@ LL | let c = 0f128; = help: add `#![feature(f128)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 6 previous errors +error[E0658]: use of unstable library feature `f128` + --> $DIR/feature-gate-f128.rs:13:24 + | +LL | let d: f128 = 1i64.into(); + | ^^^^ + | + = help: add `#![feature(f128)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: required for `f128` to implement `From` + = note: required for `i64` to implement `Into` + +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-f128.e2018.stderr b/tests/ui/feature-gates/feature-gate-f128.e2018.stderr index 7e8ea5e948dca..627010a935475 100644 --- a/tests/ui/feature-gates/feature-gate-f128.e2018.stderr +++ b/tests/ui/feature-gates/feature-gate-f128.e2018.stderr @@ -19,7 +19,27 @@ LL | let a: f128 = 100.0; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the type `f128` is unstable - --> $DIR/feature-gate-f128.rs:16:11 + --> $DIR/feature-gate-f128.rs:13:12 + | +LL | let d: f128 = 1i64.into(); + | ^^^^ + | + = note: see issue #116909 for more information + = help: add `#![feature(f128)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the type `f128` is unstable + --> $DIR/feature-gate-f128.rs:16:12 + | +LL | let e: f128 = 1u64.into(); + | ^^^^ + | + = note: see issue #116909 for more information + = help: add `#![feature(f128)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the type `f128` is unstable + --> $DIR/feature-gate-f128.rs:21:11 | LL | fn foo(a: f128) {} | ^^^^ @@ -29,7 +49,7 @@ LL | fn foo(a: f128) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the type `f128` is unstable - --> $DIR/feature-gate-f128.rs:19:8 + --> $DIR/feature-gate-f128.rs:24:8 | LL | a: f128, | ^^^^ @@ -58,6 +78,17 @@ LL | let c = 0f128; = help: add `#![feature(f128)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 6 previous errors +error[E0658]: use of unstable library feature `f128` + --> $DIR/feature-gate-f128.rs:13:24 + | +LL | let d: f128 = 1i64.into(); + | ^^^^ + | + = help: add `#![feature(f128)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: required for `f128` to implement `From` + = note: required for `i64` to implement `Into` + +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-f128.rs b/tests/ui/feature-gates/feature-gate-f128.rs index dcbe60e934ae6..13851b72c70f2 100644 --- a/tests/ui/feature-gates/feature-gate-f128.rs +++ b/tests/ui/feature-gates/feature-gate-f128.rs @@ -10,6 +10,11 @@ pub fn main() { let a: f128 = 100.0; //~ ERROR the type `f128` is unstable let b = 0.0f128; //~ ERROR the type `f128` is unstable let c = 0f128; //~ ERROR the type `f128` is unstable + let d: f128 = 1i64.into(); + //~^ ERROR the type `f128` is unstable + //~| ERROR use of unstable library feature `f128` + let e: f128 = 1u64.into(); + //~^ ERROR the type `f128` is unstable foo(1.23); }