Skip to content
/ rust Public
forked from rust-lang/rust

Commit 819568a

Browse files
authored
Rollup merge of rust-lang#123307 - tgross35:f16-f128-feature-gate-fix, r=petrochenkov
Fix f16 and f128 feature gating on different editions Apply the fix from rust-lang#123282 (comment) to correctly gates `f16` and `f128` in editions other than 2015
2 parents c8cd010 + 5afe072 commit 819568a

9 files changed

+148
-10
lines changed

compiler/rustc_resolve/src/ident.rs

+2
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
605605
&& !this.tcx.features().f16
606606
&& !ident.span.allows_unstable(sym::f16)
607607
&& finalize.is_some()
608+
&& innermost_result.is_none()
608609
{
609610
feature_err(
610611
this.tcx.sess,
@@ -618,6 +619,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
618619
&& !this.tcx.features().f128
619620
&& !ident.span.allows_unstable(sym::f128)
620621
&& finalize.is_some()
622+
&& innermost_result.is_none()
621623
{
622624
feature_err(
623625
this.tcx.sess,

tests/ui/feature-gates/feature-gate-f128.stderr tests/ui/feature-gates/feature-gate-f128.e2015.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the type `f128` is unstable
2-
--> $DIR/feature-gate-f128.rs:3:10
2+
--> $DIR/feature-gate-f128.rs:7:10
33
|
44
LL | const A: f128 = 10.0;
55
| ^^^^
@@ -9,7 +9,7 @@ LL | const A: f128 = 10.0;
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: the type `f128` is unstable
12-
--> $DIR/feature-gate-f128.rs:6:12
12+
--> $DIR/feature-gate-f128.rs:10:12
1313
|
1414
LL | let a: f128 = 100.0;
1515
| ^^^^
@@ -19,7 +19,7 @@ LL | let a: f128 = 100.0;
1919
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020

2121
error[E0658]: the type `f128` is unstable
22-
--> $DIR/feature-gate-f128.rs:11:11
22+
--> $DIR/feature-gate-f128.rs:15:11
2323
|
2424
LL | fn foo(a: f128) {}
2525
| ^^^^
@@ -29,7 +29,7 @@ LL | fn foo(a: f128) {}
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

3131
error[E0658]: the type `f128` is unstable
32-
--> $DIR/feature-gate-f128.rs:14:8
32+
--> $DIR/feature-gate-f128.rs:18:8
3333
|
3434
LL | a: f128,
3535
| ^^^^
@@ -39,7 +39,7 @@ LL | a: f128,
3939
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4040

4141
error[E0658]: the type `f128` is unstable
42-
--> $DIR/feature-gate-f128.rs:7:13
42+
--> $DIR/feature-gate-f128.rs:11:13
4343
|
4444
LL | let b = 0.0f128;
4545
| ^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error[E0658]: the type `f128` is unstable
2+
--> $DIR/feature-gate-f128.rs:7:10
3+
|
4+
LL | const A: f128 = 10.0;
5+
| ^^^^
6+
|
7+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
8+
= help: add `#![feature(f128)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: the type `f128` is unstable
12+
--> $DIR/feature-gate-f128.rs:10:12
13+
|
14+
LL | let a: f128 = 100.0;
15+
| ^^^^
16+
|
17+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
18+
= help: add `#![feature(f128)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error[E0658]: the type `f128` is unstable
22+
--> $DIR/feature-gate-f128.rs:15:11
23+
|
24+
LL | fn foo(a: f128) {}
25+
| ^^^^
26+
|
27+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
28+
= help: add `#![feature(f128)]` to the crate attributes to enable
29+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30+
31+
error[E0658]: the type `f128` is unstable
32+
--> $DIR/feature-gate-f128.rs:18:8
33+
|
34+
LL | a: f128,
35+
| ^^^^
36+
|
37+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
38+
= help: add `#![feature(f128)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
41+
error[E0658]: the type `f128` is unstable
42+
--> $DIR/feature-gate-f128.rs:11:13
43+
|
44+
LL | let b = 0.0f128;
45+
| ^^^^^^^
46+
|
47+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
48+
= help: add `#![feature(f128)]` to the crate attributes to enable
49+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50+
51+
error: aborting due to 5 previous errors
52+
53+
For more information about this error, try `rustc --explain E0658`.

tests/ui/feature-gates/feature-gate-f128.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//@ revisions: e2015 e2018
2+
//
3+
//@[e2018] edition:2018
4+
15
#![allow(unused)]
26

37
const A: f128 = 10.0; //~ ERROR the type `f128` is unstable

tests/ui/feature-gates/feature-gate-f16.stderr tests/ui/feature-gates/feature-gate-f16.e2015.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the type `f16` is unstable
2-
--> $DIR/feature-gate-f16.rs:3:10
2+
--> $DIR/feature-gate-f16.rs:7:10
33
|
44
LL | const A: f16 = 10.0;
55
| ^^^
@@ -9,7 +9,7 @@ LL | const A: f16 = 10.0;
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: the type `f16` is unstable
12-
--> $DIR/feature-gate-f16.rs:6:12
12+
--> $DIR/feature-gate-f16.rs:10:12
1313
|
1414
LL | let a: f16 = 100.0;
1515
| ^^^
@@ -19,7 +19,7 @@ LL | let a: f16 = 100.0;
1919
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020

2121
error[E0658]: the type `f16` is unstable
22-
--> $DIR/feature-gate-f16.rs:11:11
22+
--> $DIR/feature-gate-f16.rs:15:11
2323
|
2424
LL | fn foo(a: f16) {}
2525
| ^^^
@@ -29,7 +29,7 @@ LL | fn foo(a: f16) {}
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

3131
error[E0658]: the type `f16` is unstable
32-
--> $DIR/feature-gate-f16.rs:14:8
32+
--> $DIR/feature-gate-f16.rs:18:8
3333
|
3434
LL | a: f16,
3535
| ^^^
@@ -39,7 +39,7 @@ LL | a: f16,
3939
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4040

4141
error[E0658]: the type `f16` is unstable
42-
--> $DIR/feature-gate-f16.rs:7:13
42+
--> $DIR/feature-gate-f16.rs:11:13
4343
|
4444
LL | let b = 0.0f16;
4545
| ^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error[E0658]: the type `f16` is unstable
2+
--> $DIR/feature-gate-f16.rs:7:10
3+
|
4+
LL | const A: f16 = 10.0;
5+
| ^^^
6+
|
7+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
8+
= help: add `#![feature(f16)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: the type `f16` is unstable
12+
--> $DIR/feature-gate-f16.rs:10:12
13+
|
14+
LL | let a: f16 = 100.0;
15+
| ^^^
16+
|
17+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
18+
= help: add `#![feature(f16)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error[E0658]: the type `f16` is unstable
22+
--> $DIR/feature-gate-f16.rs:15:11
23+
|
24+
LL | fn foo(a: f16) {}
25+
| ^^^
26+
|
27+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
28+
= help: add `#![feature(f16)]` to the crate attributes to enable
29+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30+
31+
error[E0658]: the type `f16` is unstable
32+
--> $DIR/feature-gate-f16.rs:18:8
33+
|
34+
LL | a: f16,
35+
| ^^^
36+
|
37+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
38+
= help: add `#![feature(f16)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
41+
error[E0658]: the type `f16` is unstable
42+
--> $DIR/feature-gate-f16.rs:11:13
43+
|
44+
LL | let b = 0.0f16;
45+
| ^^^^^^
46+
|
47+
= note: see issue #116909 <https://github.com/rust-lang/rust/issues/116909> for more information
48+
= help: add `#![feature(f16)]` to the crate attributes to enable
49+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50+
51+
error: aborting due to 5 previous errors
52+
53+
For more information about this error, try `rustc --explain E0658`.

tests/ui/feature-gates/feature-gate-f16.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//@ revisions: e2015 e2018
2+
//
3+
//@[e2018] edition:2018
4+
15
#![allow(unused)]
26

37
const A: f16 = 10.0; //~ ERROR the type `f16` is unstable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: --crate-type=lib
2+
//@ check-pass
3+
//@ revisions: e2015 e2018
4+
//
5+
//@[e2018] edition:2018
6+
7+
// Verify that gates for the `f16` and `f128` features do not apply to user modules
8+
// See <https://github.com/rust-lang/rust/issues/123282>
9+
10+
mod f16 {
11+
pub fn a16() {}
12+
}
13+
14+
mod f128 {
15+
pub fn a128() {}
16+
}
17+
18+
pub use f128::a128;
19+
pub use f16::a16;

tests/ui/resolve/primitive-f16-f128-shadowed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//@ compile-flags: --crate-type=lib
22
//@ check-pass
3+
//@ revisions: e2015 e2018
4+
//
5+
//@[e2018] edition:2018
36

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

0 commit comments

Comments
 (0)