Skip to content

Commit 6f97273

Browse files
Add non-ancestor errors involving restrictions to other crates
1 parent 2f400de commit 6f97273

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

tests/ui/impl-restriction/restriction_resolution_errors.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
//@ aux-build: external-impl-restriction.rs
12
#![feature(impl_restriction)]
23
#![expect(incomplete_features)]
34

5+
extern crate external_impl_restriction as external;
6+
47
pub mod a {
58
pub enum E {}
69
pub mod d {}
@@ -53,6 +56,8 @@ pub impl(self) trait T16 {}
5356

5457
pub impl(super) trait T17 {} //~ ERROR too many leading `super` keywords [E0433]
5558

59+
pub impl(in external) trait T18 {} //~ ERROR trait implementation can only be restricted to ancestor modules
60+
5661
// Check if we can resolve paths referring to modules declared later.
5762
pub impl(in crate::j) trait L4 {} //~ ERROR trait implementation can only be restricted to ancestor modules
5863

tests/ui/impl-restriction/restriction_resolution_errors.stderr

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,77 @@
11
error: trait implementation can only be restricted to ancestor modules
2-
--> $DIR/restriction_resolution_errors.rs:14:21
2+
--> $DIR/restriction_resolution_errors.rs:17:21
33
|
44
LL | pub impl(in ::std) trait T2 {}
55
| ^^^^^
66

77
error: trait implementation can only be restricted to ancestor modules
8-
--> $DIR/restriction_resolution_errors.rs:16:21
8+
--> $DIR/restriction_resolution_errors.rs:19:21
99
|
1010
LL | pub impl(in self::c) trait T3 {}
1111
| ^^^^^^^
1212

1313
error: trait implementation can only be restricted to ancestor modules
14-
--> $DIR/restriction_resolution_errors.rs:18:21
14+
--> $DIR/restriction_resolution_errors.rs:21:21
1515
|
1616
LL | pub impl(in super::d) trait T4 {}
1717
| ^^^^^^^^
1818

1919
error[E0433]: too many leading `super` keywords
20-
--> $DIR/restriction_resolution_errors.rs:24:35
20+
--> $DIR/restriction_resolution_errors.rs:27:35
2121
|
2222
LL | pub impl(in super::super::super) trait T7 {}
2323
| ^^^^^ there are too many leading `super` keywords
2424

2525
error: trait implementation can only be restricted to ancestor modules
26-
--> $DIR/restriction_resolution_errors.rs:34:21
26+
--> $DIR/restriction_resolution_errors.rs:37:21
2727
|
2828
LL | pub impl(in self::f) trait L1 {}
2929
| ^^^^^^^
3030

3131
error: trait implementation can only be restricted to ancestor modules
32-
--> $DIR/restriction_resolution_errors.rs:38:21
32+
--> $DIR/restriction_resolution_errors.rs:41:21
3333
|
3434
LL | pub impl(in super::h) trait L3 {}
3535
| ^^^^^^^^
3636

3737
error: trait implementation can only be restricted to ancestor modules
38-
--> $DIR/restriction_resolution_errors.rs:47:13
38+
--> $DIR/restriction_resolution_errors.rs:50:13
3939
|
4040
LL | pub impl(in crate::a) trait T13 {}
4141
| ^^^^^^^^
4242

4343
error[E0433]: too many leading `super` keywords
44-
--> $DIR/restriction_resolution_errors.rs:54:10
44+
--> $DIR/restriction_resolution_errors.rs:57:10
4545
|
4646
LL | pub impl(super) trait T17 {}
4747
| ^^^^^ there are too many leading `super` keywords
4848

4949
error: trait implementation can only be restricted to ancestor modules
50-
--> $DIR/restriction_resolution_errors.rs:57:13
50+
--> $DIR/restriction_resolution_errors.rs:59:13
51+
|
52+
LL | pub impl(in external) trait T18 {}
53+
| ^^^^^^^^
54+
55+
error: trait implementation can only be restricted to ancestor modules
56+
--> $DIR/restriction_resolution_errors.rs:62:13
5157
|
5258
LL | pub impl(in crate::j) trait L4 {}
5359
| ^^^^^^^^
5460

5561
error: trait implementation can only be restricted to ancestor modules
56-
--> $DIR/restriction_resolution_errors.rs:73:21
62+
--> $DIR/restriction_resolution_errors.rs:78:21
5763
|
5864
LL | pub impl(in crate::m2) trait U2 {}
5965
| ^^^^^^^^^
6066

6167
error: trait implementation can only be restricted to ancestor modules
62-
--> $DIR/restriction_resolution_errors.rs:75:21
68+
--> $DIR/restriction_resolution_errors.rs:80:21
6369
|
6470
LL | pub impl(in m6::m5) trait U4 {}
6571
| ^^^^^^
6672

6773
error[E0433]: cannot find module or crate `a` in this scope
68-
--> $DIR/restriction_resolution_errors.rs:12:21
74+
--> $DIR/restriction_resolution_errors.rs:15:21
6975
|
7076
LL | pub impl(in a::b) trait T1 {}
7177
| ^ use of unresolved module or unlinked crate `a`
@@ -81,25 +87,25 @@ LL + use a;
8187
|
8288

8389
error[E0433]: cannot find module `c` in the crate root
84-
--> $DIR/restriction_resolution_errors.rs:20:28
90+
--> $DIR/restriction_resolution_errors.rs:23:28
8591
|
8692
LL | pub impl(in crate::c) trait T5 {}
8793
| ^ not found in the crate root
8894

8995
error[E0577]: expected module, found enum `super::E`
90-
--> $DIR/restriction_resolution_errors.rs:22:21
96+
--> $DIR/restriction_resolution_errors.rs:25:21
9197
|
9298
LL | pub impl(in super::E) trait T6 {}
9399
| ^^^^^^^^ not a module
94100

95101
error[E0577]: expected module, found enum `super::G`
96-
--> $DIR/restriction_resolution_errors.rs:36:21
102+
--> $DIR/restriction_resolution_errors.rs:39:21
97103
|
98104
LL | pub impl(in super::G) trait L2 {}
99105
| ^^^^^^^^ not a module
100106

101107
error[E0577]: expected module, found enum `crate::a::E`
102-
--> $DIR/restriction_resolution_errors.rs:49:13
108+
--> $DIR/restriction_resolution_errors.rs:52:13
103109
|
104110
LL | pub mod b {
105111
| --------- similarly named module `b` defined here
@@ -114,7 +120,7 @@ LL + pub impl(in crate::a::b) trait T14 {}
114120
|
115121

116122
error[E0577]: expected module, found enum `crate::I`
117-
--> $DIR/restriction_resolution_errors.rs:59:13
123+
--> $DIR/restriction_resolution_errors.rs:64:13
118124
|
119125
LL | pub mod a {
120126
| --------- similarly named module `a` defined here
@@ -129,12 +135,12 @@ LL + pub impl(in crate::a) trait L5 {}
129135
|
130136

131137
error[E0577]: expected module, found enum `m7`
132-
--> $DIR/restriction_resolution_errors.rs:76:21
138+
--> $DIR/restriction_resolution_errors.rs:81:21
133139
|
134140
LL | pub impl(in m7) trait U5 {}
135141
| ^^ not a module
136142

137-
error: aborting due to 18 previous errors
143+
error: aborting due to 19 previous errors
138144

139145
Some errors have detailed explanations: E0433, E0577.
140146
For more information about an error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)