Rollup merge of #139294 - beetrees:fix-f16-f128-literal-feature-gate, r=fmease
Fix the `f16`/`f128` feature gates on integer literals The feature gating logic for `f16`/`f128` currently only checks float literals, meaning this code currently compiles with no feature gates on stable ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=b0c0e285ccb822fc7e2abc595557886b)): ```rust fn main() { let a = 1f16; let b = 1f128; dbg!(a, b); } ``` This PR fixes that. Tracking issue: #116909
This commit is contained in:
commit
29c0fe747a
7 changed files with 66 additions and 22 deletions
|
@ -332,8 +332,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
ast::ExprKind::TryBlock(_) => {
|
ast::ExprKind::TryBlock(_) => {
|
||||||
gate!(&self, try_blocks, e.span, "`try` expression is experimental");
|
gate!(&self, try_blocks, e.span, "`try` expression is experimental");
|
||||||
}
|
}
|
||||||
ast::ExprKind::Lit(token::Lit { kind: token::LitKind::Float, suffix, .. }) => {
|
ast::ExprKind::Lit(token::Lit {
|
||||||
match suffix {
|
kind: token::LitKind::Float | token::LitKind::Integer,
|
||||||
|
suffix,
|
||||||
|
..
|
||||||
|
}) => match suffix {
|
||||||
Some(sym::f16) => {
|
Some(sym::f16) => {
|
||||||
gate!(&self, f16, e.span, "the type `f16` is unstable")
|
gate!(&self, f16, e.span, "the type `f16` is unstable")
|
||||||
}
|
}
|
||||||
|
@ -341,8 +344,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
gate!(&self, f128, e.span, "the type `f128` is unstable")
|
gate!(&self, f128, e.span, "the type `f128` is unstable")
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
},
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
visit::walk_expr(self, e)
|
visit::walk_expr(self, e)
|
||||||
|
|
|
@ -19,7 +19,7 @@ LL | let a: f128 = 100.0;
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= 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
|
error[E0658]: the type `f128` is unstable
|
||||||
--> $DIR/feature-gate-f128.rs:15:11
|
--> $DIR/feature-gate-f128.rs:16:11
|
||||||
|
|
|
|
||||||
LL | fn foo(a: f128) {}
|
LL | fn foo(a: f128) {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -29,7 +29,7 @@ LL | fn foo(a: f128) {}
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= 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
|
error[E0658]: the type `f128` is unstable
|
||||||
--> $DIR/feature-gate-f128.rs:18:8
|
--> $DIR/feature-gate-f128.rs:19:8
|
||||||
|
|
|
|
||||||
LL | a: f128,
|
LL | a: f128,
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -48,6 +48,16 @@ LL | let b = 0.0f128;
|
||||||
= help: add `#![feature(f128)]` to the crate attributes to enable
|
= 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: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error[E0658]: the type `f128` is unstable
|
||||||
|
--> $DIR/feature-gate-f128.rs:12:13
|
||||||
|
|
|
||||||
|
LL | let c = 0f128;
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= 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: aborting due to 6 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
|
@ -19,7 +19,7 @@ LL | let a: f128 = 100.0;
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= 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
|
error[E0658]: the type `f128` is unstable
|
||||||
--> $DIR/feature-gate-f128.rs:15:11
|
--> $DIR/feature-gate-f128.rs:16:11
|
||||||
|
|
|
|
||||||
LL | fn foo(a: f128) {}
|
LL | fn foo(a: f128) {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -29,7 +29,7 @@ LL | fn foo(a: f128) {}
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= 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
|
error[E0658]: the type `f128` is unstable
|
||||||
--> $DIR/feature-gate-f128.rs:18:8
|
--> $DIR/feature-gate-f128.rs:19:8
|
||||||
|
|
|
|
||||||
LL | a: f128,
|
LL | a: f128,
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -48,6 +48,16 @@ LL | let b = 0.0f128;
|
||||||
= help: add `#![feature(f128)]` to the crate attributes to enable
|
= 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: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error[E0658]: the type `f128` is unstable
|
||||||
|
--> $DIR/feature-gate-f128.rs:12:13
|
||||||
|
|
|
||||||
|
LL | let c = 0f128;
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= 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: aborting due to 6 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
|
@ -9,6 +9,7 @@ const A: f128 = 10.0; //~ ERROR the type `f128` is unstable
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let a: f128 = 100.0; //~ ERROR the type `f128` is unstable
|
let a: f128 = 100.0; //~ ERROR the type `f128` is unstable
|
||||||
let b = 0.0f128; //~ 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
|
||||||
foo(1.23);
|
foo(1.23);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ LL | let a: f16 = 100.0;
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: the type `f16` is unstable
|
error[E0658]: the type `f16` is unstable
|
||||||
--> $DIR/feature-gate-f16.rs:15:11
|
--> $DIR/feature-gate-f16.rs:16:11
|
||||||
|
|
|
|
||||||
LL | fn foo(a: f16) {}
|
LL | fn foo(a: f16) {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -29,7 +29,7 @@ LL | fn foo(a: f16) {}
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: the type `f16` is unstable
|
error[E0658]: the type `f16` is unstable
|
||||||
--> $DIR/feature-gate-f16.rs:18:8
|
--> $DIR/feature-gate-f16.rs:19:8
|
||||||
|
|
|
|
||||||
LL | a: f16,
|
LL | a: f16,
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -48,6 +48,16 @@ LL | let b = 0.0f16;
|
||||||
= help: add `#![feature(f16)]` to the crate attributes to enable
|
= help: add `#![feature(f16)]` 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: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error[E0658]: the type `f16` is unstable
|
||||||
|
--> $DIR/feature-gate-f16.rs:12:13
|
||||||
|
|
|
||||||
|
LL | let c = 0f16;
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
|
||||||
|
= help: add `#![feature(f16)]` 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
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
|
@ -19,7 +19,7 @@ LL | let a: f16 = 100.0;
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: the type `f16` is unstable
|
error[E0658]: the type `f16` is unstable
|
||||||
--> $DIR/feature-gate-f16.rs:15:11
|
--> $DIR/feature-gate-f16.rs:16:11
|
||||||
|
|
|
|
||||||
LL | fn foo(a: f16) {}
|
LL | fn foo(a: f16) {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -29,7 +29,7 @@ LL | fn foo(a: f16) {}
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: the type `f16` is unstable
|
error[E0658]: the type `f16` is unstable
|
||||||
--> $DIR/feature-gate-f16.rs:18:8
|
--> $DIR/feature-gate-f16.rs:19:8
|
||||||
|
|
|
|
||||||
LL | a: f16,
|
LL | a: f16,
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -48,6 +48,16 @@ LL | let b = 0.0f16;
|
||||||
= help: add `#![feature(f16)]` to the crate attributes to enable
|
= help: add `#![feature(f16)]` 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: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error[E0658]: the type `f16` is unstable
|
||||||
|
--> $DIR/feature-gate-f16.rs:12:13
|
||||||
|
|
|
||||||
|
LL | let c = 0f16;
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
|
||||||
|
= help: add `#![feature(f16)]` 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
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
|
@ -9,6 +9,7 @@ const A: f16 = 10.0; //~ ERROR the type `f16` is unstable
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let a: f16 = 100.0; //~ ERROR the type `f16` is unstable
|
let a: f16 = 100.0; //~ ERROR the type `f16` is unstable
|
||||||
let b = 0.0f16; //~ ERROR the type `f16` is unstable
|
let b = 0.0f16; //~ ERROR the type `f16` is unstable
|
||||||
|
let c = 0f16; //~ ERROR the type `f16` is unstable
|
||||||
foo(1.23);
|
foo(1.23);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue