Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -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")]);
Expand All @@ -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
Expand Down
37 changes: 34 additions & 3 deletions tests/ui/feature-gates/feature-gate-f128.e2015.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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) {}
| ^^^^
Expand All @@ -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,
| ^^^^
Expand Down Expand Up @@ -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<i64>`
= note: required for `i64` to implement `Into<f128>`

error: aborting due to 9 previous errors

For more information about this error, try `rustc --explain E0658`.
37 changes: 34 additions & 3 deletions tests/ui/feature-gates/feature-gate-f128.e2018.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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) {}
| ^^^^
Expand All @@ -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,
| ^^^^
Expand Down Expand Up @@ -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<i64>`
= note: required for `i64` to implement `Into<f128>`

error: aborting due to 9 previous errors

For more information about this error, try `rustc --explain E0658`.
5 changes: 5 additions & 0 deletions tests/ui/feature-gates/feature-gate-f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading