Skip to content

Commit 0e6efe5

Browse files
Update UI tests
1 parent 614994f commit 0e6efe5

9 files changed

Lines changed: 155 additions & 479 deletions

tests/ui/impl-restriction/feature-gate-impl-restriction.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ pub impl(in crate) trait BarInCrate {} //[without_gate]~ ERROR `impl` restrictio
1111

1212
mod foo {
1313
pub impl(in crate::foo) trait Baz {} //[without_gate]~ ERROR `impl` restrictions are experimental
14-
pub unsafe impl(super) trait BazUnsafeSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental
15-
pub auto impl(self) trait BazAutoSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental
16-
pub const impl(in self) trait BazConst {} //[without_gate]~ ERROR `impl` restrictions are experimental
14+
pub impl(super) unsafe trait BazUnsafeSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental
15+
pub impl(self) auto trait BazAutoSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental
16+
pub impl(in self) const trait BazConst {} //[without_gate]~ ERROR `impl` restrictions are experimental
1717

1818
mod foo_inner {
1919
pub impl(in crate::foo::foo_inner) trait Qux {} //[without_gate]~ ERROR `impl` restrictions are experimental
20-
pub unsafe auto impl(in crate::foo::foo_inner) trait QuxAutoUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental
21-
pub const unsafe impl(in crate::foo::foo_inner) trait QuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental
20+
pub impl(in crate::foo::foo_inner) unsafe auto trait QuxAutoUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental
21+
pub impl(in crate::foo::foo_inner) const unsafe trait QuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental
2222
}
2323

2424
#[cfg(false)]
2525
pub impl(crate) trait Bar {} //[without_gate]~ ERROR `impl` restrictions are experimental
2626
#[cfg(false)]
2727
pub impl(in crate) trait BarInCrate {} //[without_gate]~ ERROR `impl` restrictions are experimental
2828
#[cfg(false)]
29-
pub unsafe impl(self) trait BazUnsafeSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental
29+
pub impl(self) unsafe trait BazUnsafeSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental
3030
#[cfg(false)]
31-
pub auto impl(in super) trait BazAutoSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental
31+
pub impl(in super) auto trait BazAutoSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental
3232
#[cfg(false)]
33-
pub const impl(super) trait BazConstSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental
33+
pub impl(super) const trait BazConstSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental
3434

3535
#[cfg(false)]
3636
mod cfged_out_foo {
3737
pub impl(in crate::foo::cfged_out_foo) trait CfgedOutQux {} //[without_gate]~ ERROR `impl` restrictions are experimental
38-
pub unsafe auto impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxUnsafeAuto {} //[without_gate]~ ERROR `impl` restrictions are experimental
39-
pub const unsafe impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental
38+
pub impl(in crate::foo::cfged_out_foo) unsafe auto trait CfgedOutQuxUnsafeAuto {} //[without_gate]~ ERROR `impl` restrictions are experimental
39+
pub impl(in crate::foo::cfged_out_foo) const unsafe trait CfgedOutQuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental
4040
}
4141

4242
// auto traits cannot be const, so we do not include these combinations in the test.

tests/ui/impl-restriction/feature-gate-impl-restriction.without_gate.stderr

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,30 @@ LL | pub impl(in crate::foo) trait Baz {}
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

3131
error[E0658]: `impl` restrictions are experimental
32-
--> $DIR/feature-gate-impl-restriction.rs:14:16
32+
--> $DIR/feature-gate-impl-restriction.rs:14:9
3333
|
34-
LL | pub unsafe impl(super) trait BazUnsafeSuper {}
35-
| ^^^^^^^^^^^
34+
LL | pub impl(super) unsafe trait BazUnsafeSuper {}
35+
| ^^^^^^^^^^^
3636
|
3737
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
3838
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
3939
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4040

4141
error[E0658]: `impl` restrictions are experimental
42-
--> $DIR/feature-gate-impl-restriction.rs:15:14
42+
--> $DIR/feature-gate-impl-restriction.rs:15:9
4343
|
44-
LL | pub auto impl(self) trait BazAutoSelf {}
45-
| ^^^^^^^^^^
44+
LL | pub impl(self) auto trait BazAutoSelf {}
45+
| ^^^^^^^^^^
4646
|
4747
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
4848
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
4949
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
5050

5151
error[E0658]: `impl` restrictions are experimental
52-
--> $DIR/feature-gate-impl-restriction.rs:16:15
52+
--> $DIR/feature-gate-impl-restriction.rs:16:9
5353
|
54-
LL | pub const impl(in self) trait BazConst {}
55-
| ^^^^^^^^^^^^^
54+
LL | pub impl(in self) const trait BazConst {}
55+
| ^^^^^^^^^^^^^
5656
|
5757
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
5858
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
@@ -69,20 +69,20 @@ LL | pub impl(in crate::foo::foo_inner) trait Qux {}
6969
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
7070

7171
error[E0658]: `impl` restrictions are experimental
72-
--> $DIR/feature-gate-impl-restriction.rs:20:25
72+
--> $DIR/feature-gate-impl-restriction.rs:20:13
7373
|
74-
LL | ... pub unsafe auto impl(in crate::foo::foo_inner) trait QuxAutoUnsafe {}
75-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74+
LL | ... pub impl(in crate::foo::foo_inner) unsafe auto trait QuxAutoUnsafe {}
75+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7676
|
7777
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
7878
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
7979
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
8080

8181
error[E0658]: `impl` restrictions are experimental
82-
--> $DIR/feature-gate-impl-restriction.rs:21:26
82+
--> $DIR/feature-gate-impl-restriction.rs:21:13
8383
|
84-
LL | ... pub const unsafe impl(in crate::foo::foo_inner) trait QuxConstUnsafe {}
85-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84+
LL | ... pub impl(in crate::foo::foo_inner) const unsafe trait QuxConstUnsafe {}
85+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8686
|
8787
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
8888
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
@@ -109,30 +109,30 @@ LL | pub impl(in crate) trait BarInCrate {}
109109
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
110110

111111
error[E0658]: `impl` restrictions are experimental
112-
--> $DIR/feature-gate-impl-restriction.rs:29:16
112+
--> $DIR/feature-gate-impl-restriction.rs:29:9
113113
|
114-
LL | pub unsafe impl(self) trait BazUnsafeSelf {}
115-
| ^^^^^^^^^^
114+
LL | pub impl(self) unsafe trait BazUnsafeSelf {}
115+
| ^^^^^^^^^^
116116
|
117117
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
118118
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
119119
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
120120

121121
error[E0658]: `impl` restrictions are experimental
122-
--> $DIR/feature-gate-impl-restriction.rs:31:14
122+
--> $DIR/feature-gate-impl-restriction.rs:31:9
123123
|
124-
LL | pub auto impl(in super) trait BazAutoSuper {}
125-
| ^^^^^^^^^^^^^^
124+
LL | pub impl(in super) auto trait BazAutoSuper {}
125+
| ^^^^^^^^^^^^^^
126126
|
127127
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
128128
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
129129
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
130130

131131
error[E0658]: `impl` restrictions are experimental
132-
--> $DIR/feature-gate-impl-restriction.rs:33:15
132+
--> $DIR/feature-gate-impl-restriction.rs:33:9
133133
|
134-
LL | pub const impl(super) trait BazConstSuper {}
135-
| ^^^^^^^^^^^
134+
LL | pub impl(super) const trait BazConstSuper {}
135+
| ^^^^^^^^^^^
136136
|
137137
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
138138
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
@@ -149,20 +149,20 @@ LL | pub impl(in crate::foo::cfged_out_foo) trait CfgedOutQux {}
149149
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
150150

151151
error[E0658]: `impl` restrictions are experimental
152-
--> $DIR/feature-gate-impl-restriction.rs:38:25
152+
--> $DIR/feature-gate-impl-restriction.rs:38:13
153153
|
154-
LL | ... pub unsafe auto impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxUnsafeAuto {}
155-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154+
LL | ... pub impl(in crate::foo::cfged_out_foo) unsafe auto trait CfgedOutQuxUnsafeAuto {}
155+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156156
|
157157
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
158158
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
159159
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
160160

161161
error[E0658]: `impl` restrictions are experimental
162-
--> $DIR/feature-gate-impl-restriction.rs:39:26
162+
--> $DIR/feature-gate-impl-restriction.rs:39:13
163163
|
164-
LL | ... pub const unsafe impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxConstUnsafe {}
165-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164+
LL | ... pub impl(in crate::foo::cfged_out_foo) const unsafe trait CfgedOutQuxConstUnsafe {}
165+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166166
|
167167
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
168168
= help: add `#![feature(impl_restriction)]` to the crate attributes to enable
Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
//@ compile-flags: --crate-type=lib
2-
//@ revisions: with_gate without_gate
3-
#![warn(incomplete_features)]
4-
#![cfg_attr(with_gate, feature(impl_restriction))]
5-
//[with_gate]~^ WARN the feature `impl_restriction` is incomplete and may not be safe to use and/or cause compiler crashes
6-
#![feature(auto_traits, const_trait_impl)]
1+
#![feature(impl_restriction, auto_traits, const_trait_impl)]
2+
#![expect(incomplete_features)]
73

84
mod foo {
95
pub impl(crate::foo) trait Baz {} //~ ERROR incorrect `impl` restriction
10-
//[without_gate]~^ ERROR `impl` restrictions are experimental
11-
pub unsafe impl(crate::foo) trait BazUnsafe {} //~ ERROR incorrect `impl` restriction
12-
//[without_gate]~^ ERROR `impl` restrictions are experimental
13-
pub auto impl(crate::foo) trait BazAuto {} //~ ERROR incorrect `impl` restriction
14-
//[without_gate]~^ ERROR `impl` restrictions are experimental
15-
pub const impl(crate::foo) trait BazConst {} //~ ERROR incorrect `impl` restriction
16-
//[without_gate]~^ ERROR `impl` restrictions are experimental
17-
pub const unsafe impl(crate::foo) trait BazConstUnsafe {} //~ ERROR incorrect `impl` restriction
18-
//[without_gate]~^ ERROR `impl` restrictions are experimental
19-
pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {} //~ ERROR incorrect `impl` restriction
20-
//[without_gate]~^ ERROR `impl` restrictions are experimental
6+
pub impl(crate::foo) unsafe trait BazUnsafe {} //~ ERROR incorrect `impl` restriction
7+
pub impl(crate::foo) auto trait BazAuto {} //~ ERROR incorrect `impl` restriction
8+
pub impl(crate::foo) const trait BazConst {} //~ ERROR incorrect `impl` restriction
9+
pub impl(crate::foo) const unsafe trait BazConstUnsafe {} //~ ERROR incorrect `impl` restriction
10+
pub impl(crate::foo) unsafe auto trait BazUnsafeAuto {} //~ ERROR incorrect `impl` restriction
11+
12+
// FIXME: The positioning of `impl(..)` may be confusing.
13+
// When users get the keyword order wrong, the compiler currently emits
14+
// a generic "unexpected token" error, which is not very helpful.
15+
// In the future, we could improve diagnostics by detecting misordered
16+
// keywords and suggesting the correct order.
17+
pub unsafe impl(crate::foo) trait BadOrder1 {} //~ ERROR expected one of `for`, `where`, or `{`, found keyword `trait`
18+
19+
// FIXME: The following cases are not checked for now,
20+
// as the compiler aborts due to the previous syntax error in `BadOrder1`.
21+
// In the future, we could recover from such errors and continue compilation.
22+
pub auto impl(crate::foo) trait BadOrder2 {}
23+
pub const impl(crate::foo) trait BadOrder3 {}
24+
pub unsafe auto impl(crate::foo) trait BadOrder4 {}
25+
pub const unsafe impl(crate::foo) trait BadOrder5 {}
26+
pub unsafe impl(crate::foo) auto trait BadOrder6 {}
27+
pub const impl(crate::foo) unsafe trait BadOrder7 {}
2128
}
29+
30+
fn main() {}

tests/ui/impl-restriction/recover-incorrect-impl-restriction.with_gate.stderr renamed to tests/ui/impl-restriction/recover-incorrect-impl-restriction.stderr

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: incorrect `impl` restriction
2-
--> $DIR/recover-incorrect-impl-restriction.rs:9:14
2+
--> $DIR/recover-incorrect-impl-restriction.rs:5:14
33
|
44
LL | pub impl(crate::foo) trait Baz {}
55
| ^^^^^^^^^^
@@ -15,10 +15,10 @@ LL | pub impl(in crate::foo) trait Baz {}
1515
| ++
1616

1717
error: incorrect `impl` restriction
18-
--> $DIR/recover-incorrect-impl-restriction.rs:11:21
18+
--> $DIR/recover-incorrect-impl-restriction.rs:6:14
1919
|
20-
LL | pub unsafe impl(crate::foo) trait BazUnsafe {}
21-
| ^^^^^^^^^^
20+
LL | pub impl(crate::foo) unsafe trait BazUnsafe {}
21+
| ^^^^^^^^^^
2222
|
2323
= help: some possible `impl` restrictions are:
2424
`impl(crate)`: can only be implemented in the current crate
@@ -27,14 +27,14 @@ LL | pub unsafe impl(crate::foo) trait BazUnsafe {}
2727
`impl(in path::to::module)`: can only be implemented in the specified path
2828
help: help: use `in` to restrict implementations to the path `crate::foo`
2929
|
30-
LL | pub unsafe impl(in crate::foo) trait BazUnsafe {}
31-
| ++
30+
LL | pub impl(in crate::foo) unsafe trait BazUnsafe {}
31+
| ++
3232

3333
error: incorrect `impl` restriction
34-
--> $DIR/recover-incorrect-impl-restriction.rs:13:19
34+
--> $DIR/recover-incorrect-impl-restriction.rs:7:14
3535
|
36-
LL | pub auto impl(crate::foo) trait BazAuto {}
37-
| ^^^^^^^^^^
36+
LL | pub impl(crate::foo) auto trait BazAuto {}
37+
| ^^^^^^^^^^
3838
|
3939
= help: some possible `impl` restrictions are:
4040
`impl(crate)`: can only be implemented in the current crate
@@ -43,14 +43,14 @@ LL | pub auto impl(crate::foo) trait BazAuto {}
4343
`impl(in path::to::module)`: can only be implemented in the specified path
4444
help: help: use `in` to restrict implementations to the path `crate::foo`
4545
|
46-
LL | pub auto impl(in crate::foo) trait BazAuto {}
47-
| ++
46+
LL | pub impl(in crate::foo) auto trait BazAuto {}
47+
| ++
4848

4949
error: incorrect `impl` restriction
50-
--> $DIR/recover-incorrect-impl-restriction.rs:15:20
50+
--> $DIR/recover-incorrect-impl-restriction.rs:8:14
5151
|
52-
LL | pub const impl(crate::foo) trait BazConst {}
53-
| ^^^^^^^^^^
52+
LL | pub impl(crate::foo) const trait BazConst {}
53+
| ^^^^^^^^^^
5454
|
5555
= help: some possible `impl` restrictions are:
5656
`impl(crate)`: can only be implemented in the current crate
@@ -59,14 +59,14 @@ LL | pub const impl(crate::foo) trait BazConst {}
5959
`impl(in path::to::module)`: can only be implemented in the specified path
6060
help: help: use `in` to restrict implementations to the path `crate::foo`
6161
|
62-
LL | pub const impl(in crate::foo) trait BazConst {}
63-
| ++
62+
LL | pub impl(in crate::foo) const trait BazConst {}
63+
| ++
6464

6565
error: incorrect `impl` restriction
66-
--> $DIR/recover-incorrect-impl-restriction.rs:17:27
66+
--> $DIR/recover-incorrect-impl-restriction.rs:9:14
6767
|
68-
LL | pub const unsafe impl(crate::foo) trait BazConstUnsafe {}
69-
| ^^^^^^^^^^
68+
LL | pub impl(crate::foo) const unsafe trait BazConstUnsafe {}
69+
| ^^^^^^^^^^
7070
|
7171
= help: some possible `impl` restrictions are:
7272
`impl(crate)`: can only be implemented in the current crate
@@ -75,14 +75,14 @@ LL | pub const unsafe impl(crate::foo) trait BazConstUnsafe {}
7575
`impl(in path::to::module)`: can only be implemented in the specified path
7676
help: help: use `in` to restrict implementations to the path `crate::foo`
7777
|
78-
LL | pub const unsafe impl(in crate::foo) trait BazConstUnsafe {}
79-
| ++
78+
LL | pub impl(in crate::foo) const unsafe trait BazConstUnsafe {}
79+
| ++
8080

8181
error: incorrect `impl` restriction
82-
--> $DIR/recover-incorrect-impl-restriction.rs:19:26
82+
--> $DIR/recover-incorrect-impl-restriction.rs:10:14
8383
|
84-
LL | pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {}
85-
| ^^^^^^^^^^
84+
LL | pub impl(crate::foo) unsafe auto trait BazUnsafeAuto {}
85+
| ^^^^^^^^^^
8686
|
8787
= help: some possible `impl` restrictions are:
8888
`impl(crate)`: can only be implemented in the current crate
@@ -91,21 +91,14 @@ LL | pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {}
9191
`impl(in path::to::module)`: can only be implemented in the specified path
9292
help: help: use `in` to restrict implementations to the path `crate::foo`
9393
|
94-
LL | pub unsafe auto impl(in crate::foo) trait BazUnsafeAuto {}
95-
| ++
94+
LL | pub impl(in crate::foo) unsafe auto trait BazUnsafeAuto {}
95+
| ++
9696

97-
warning: the feature `impl_restriction` is incomplete and may not be safe to use and/or cause compiler crashes
98-
--> $DIR/recover-incorrect-impl-restriction.rs:4:32
99-
|
100-
LL | #![cfg_attr(with_gate, feature(impl_restriction))]
101-
| ^^^^^^^^^^^^^^^^
102-
|
103-
= note: see issue #105077 <https://github.com/rust-lang/rust/issues/105077> for more information
104-
note: the lint level is defined here
105-
--> $DIR/recover-incorrect-impl-restriction.rs:3:9
97+
error: expected one of `for`, `where`, or `{`, found keyword `trait`
98+
--> $DIR/recover-incorrect-impl-restriction.rs:17:33
10699
|
107-
LL | #![warn(incomplete_features)]
108-
| ^^^^^^^^^^^^^^^^^^^
100+
LL | pub unsafe impl(crate::foo) trait BadOrder1 {}
101+
| ^^^^^ expected one of `for`, `where`, or `{`
109102

110-
error: aborting due to 6 previous errors; 1 warning emitted
103+
error: aborting due to 7 previous errors
111104

0 commit comments

Comments
 (0)