Skip to content

Commit 9430b81

Browse files
committed
Remove the special case of ::self after edition 2018
1 parent 36a7c6c commit 9430b81

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,12 +1838,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18381838
}
18391839
}
18401840

1841-
// Support `...::self`, but deny `::self` after edition 2018
1842-
let allow_trailing_self = is_last
1843-
&& name == kw::SelfLower
1844-
&& segment_idx > 0
1845-
&& (path[segment_idx - 1].ident.name != kw::PathRoot
1846-
|| self.path_root_is_crate_root(path[segment_idx - 1].ident));
1841+
let allow_trailing_self = is_last && name == kw::SelfLower;
18471842

18481843
// Report special messages for path segment keywords in wrong positions.
18491844
if ident.is_path_segment_keyword() && segment_idx != 0 && !allow_trailing_self {

tests/ui/use/use-path-segment-kw.e2018.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,12 @@ error[E0573]: expected type, found module `self`
812812
LL | type D1 = self;
813813
| ^^^^ not a type
814814

815+
error[E0425]: cannot find crate `self` in the list of imported crates
816+
--> $DIR/use-path-segment-kw.rs:175:21
817+
|
818+
LL | type D2 = ::self;
819+
| ^^^^ not found in the list of imported crates
820+
815821
error[E0573]: expected type, found module `foobar::self`
816822
--> $DIR/use-path-segment-kw.rs:185:19
817823
|
@@ -978,13 +984,7 @@ error[E0433]: `super` in paths can only be used in start position
978984
LL | type C4 = crate::super;
979985
| ^^^^^ can only be used in path start position
980986

981-
error[E0433]: global paths cannot start with `self`
982-
--> $DIR/use-path-segment-kw.rs:175:21
983-
|
984-
LL | type D2 = ::self;
985-
| ^^^^ cannot start with this
986-
987987
error: aborting due to 114 previous errors
988988

989-
Some errors have detailed explanations: E0433, E0573.
990-
For more information about an error, try `rustc --explain E0433`.
989+
Some errors have detailed explanations: E0425, E0433, E0573.
990+
For more information about an error, try `rustc --explain E0425`.

tests/ui/use/use-path-segment-kw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub mod foo {
174174

175175
type D2 = ::self;
176176
//[e2015]~^ ERROR expected type, found module `::self`
177-
//[e2018]~^^ ERROR global paths cannot start with `self`
177+
//[e2018]~^^ ERROR cannot find crate `self` in the list of imported crates
178178
use ::self; //[e2018]~ ERROR extern prelude cannot be imported
179179
//[e2015]~^ ERROR imports need to be explicitly named
180180
use ::self as _self2; //[e2018]~ ERROR extern prelude cannot be imported

tests/ui/use/use-self-at-end.e2018.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ error[E0573]: expected type, found module `crate::x::self`
266266
LL | type E = crate::x::self;
267267
| ^^^^^^^^^^^^^^ not a type
268268

269+
error[E0425]: cannot find crate `self` in the list of imported crates
270+
--> $DIR/use-self-at-end.rs:45:20
271+
|
272+
LL | type F = ::self;
273+
| ^^^^ not found in the list of imported crates
274+
269275
error[E0223]: ambiguous associated type
270276
--> $DIR/use-self-at-end.rs:62:18
271277
|
@@ -292,13 +298,7 @@ help: if this is a dyn-compatible trait, use `dyn`
292298
LL | type J = dyn super::Trait::self;
293299
| +++
294300

295-
error[E0433]: global paths cannot start with `self`
296-
--> $DIR/use-self-at-end.rs:45:20
297-
|
298-
LL | type F = ::self;
299-
| ^^^^ cannot start with this
300-
301301
error: aborting due to 36 previous errors; 1 warning emitted
302302

303-
Some errors have detailed explanations: E0223, E0252, E0432, E0433, E0573.
303+
Some errors have detailed explanations: E0223, E0252, E0425, E0432, E0433, E0573.
304304
For more information about an error, try `rustc --explain E0223`.

tests/ui/use/use-self-at-end.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod x {
4444

4545
type F = ::self;
4646
//[e2015]~^ ERROR expected type, found module `::self`
47-
//[e2018]~^^ ERROR global paths cannot start with `self`
47+
//[e2018]~^^ ERROR cannot find crate `self` in the list of imported crates
4848
pub use ::self;
4949
//[e2015]~^ ERROR imports need to be explicitly named
5050
//[e2018]~^^ ERROR extern prelude cannot be imported

0 commit comments

Comments
 (0)