Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix f16 and f128 feature gating on different editions #123307

Merged
merged 2 commits into from
Apr 4, 2024
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
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
&& !this.tcx.features().f16
&& !ident.span.allows_unstable(sym::f16)
&& finalize.is_some()
&& innermost_result.is_none()
{
feature_err(
this.tcx.sess,
Expand All @@ -618,6 +619,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
&& !this.tcx.features().f128
&& !ident.span.allows_unstable(sym::f128)
&& finalize.is_some()
&& innermost_result.is_none()
{
feature_err(
this.tcx.sess,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:3:10
--> $DIR/feature-gate-f128.rs:7:10
|
LL | const A: f128 = 10.0;
| ^^^^
Expand All @@ -9,7 +9,7 @@ LL | const A: f128 = 10.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:6:12
--> $DIR/feature-gate-f128.rs:10:12
|
LL | let a: f128 = 100.0;
| ^^^^
Expand All @@ -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

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:11:11
--> $DIR/feature-gate-f128.rs:15:11
|
LL | fn foo(a: f128) {}
| ^^^^
Expand All @@ -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

error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:14:8
--> $DIR/feature-gate-f128.rs:18:8
|
LL | a: f128,
| ^^^^
Expand All @@ -39,7 +39,7 @@ LL | 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:7:13
--> $DIR/feature-gate-f128.rs:11:13
|
LL | let b = 0.0f128;
| ^^^^^^^
Expand Down
53 changes: 53 additions & 0 deletions tests/ui/feature-gates/feature-gate-f128.e2018.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
error[E0658]: the type `f128` is unstable
--> $DIR/feature-gate-f128.rs:7:10
|
LL | const A: f128 = 10.0;
| ^^^^
|
= 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:10:12
|
LL | let a: f128 = 100.0;
| ^^^^
|
= 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:15:11
|
LL | fn foo(a: f128) {}
| ^^^^
|
= 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:18:8
|
LL | a: f128,
| ^^^^
|
= 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:11:13
|
LL | let b = 0.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 5 previous errors

For more information about this error, try `rustc --explain E0658`.
4 changes: 4 additions & 0 deletions tests/ui/feature-gates/feature-gate-f128.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

#![allow(unused)]

const A: f128 = 10.0; //~ ERROR the type `f128` is unstable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:3:10
--> $DIR/feature-gate-f16.rs:7:10
|
LL | const A: f16 = 10.0;
| ^^^
Expand All @@ -9,7 +9,7 @@ LL | const A: f16 = 10.0;
= 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
--> $DIR/feature-gate-f16.rs:6:12
--> $DIR/feature-gate-f16.rs:10:12
|
LL | let a: f16 = 100.0;
| ^^^
Expand All @@ -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

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:11:11
--> $DIR/feature-gate-f16.rs:15:11
|
LL | fn foo(a: f16) {}
| ^^^
Expand All @@ -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

error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:14:8
--> $DIR/feature-gate-f16.rs:18:8
|
LL | a: f16,
| ^^^
Expand All @@ -39,7 +39,7 @@ LL | a: f16,
= 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
--> $DIR/feature-gate-f16.rs:7:13
--> $DIR/feature-gate-f16.rs:11:13
|
LL | let b = 0.0f16;
| ^^^^^^
Expand Down
53 changes: 53 additions & 0 deletions tests/ui/feature-gates/feature-gate-f16.e2018.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
error[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:7:10
|
LL | const A: f16 = 10.0;
| ^^^
|
= 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[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:10:12
|
LL | let a: f16 = 100.0;
| ^^^
|
= 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[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:15:11
|
LL | fn foo(a: f16) {}
| ^^^
|
= 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[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:18:8
|
LL | a: f16,
| ^^^
|
= 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[E0658]: the type `f16` is unstable
--> $DIR/feature-gate-f16.rs:11:13
|
LL | let b = 0.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 5 previous errors

For more information about this error, try `rustc --explain E0658`.
4 changes: 4 additions & 0 deletions tests/ui/feature-gates/feature-gate-f16.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

#![allow(unused)]

const A: f16 = 10.0; //~ ERROR the type `f16` is unstable
Expand Down
19 changes: 19 additions & 0 deletions tests/ui/resolve/primitive-f16-f128-shadowed-mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ compile-flags: --crate-type=lib
//@ check-pass
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

// Verify that gates for the `f16` and `f128` features do not apply to user modules
// See <https://github.com/rust-lang/rust/issues/123282>

mod f16 {
pub fn a16() {}
}

mod f128 {
pub fn a128() {}
}

pub use f128::a128;
pub use f16::a16;
3 changes: 3 additions & 0 deletions tests/ui/resolve/primitive-f16-f128-shadowed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//@ compile-flags: --crate-type=lib
//@ check-pass
//@ revisions: e2015 e2018
//
//@[e2018] edition:2018

// Verify that gates for the `f16` and `f128` features do not apply to user types

Expand Down
Loading