Conversation
This comment has been minimized.
This comment has been minimized.
178d259 to
abd6031
Compare
This comment has been minimized.
This comment has been minimized.
abd6031 to
3102edf
Compare
This comment has been minimized.
This comment has been minimized.
3102edf to
c206a47
Compare
self appear at the end of any paths in importsself at the end of any paths in imports
This comment has been minimized.
This comment has been minimized.
c206a47 to
d7a8a0a
Compare
d7a8a0a to
d845289
Compare
This comment has been minimized.
This comment has been minimized.
d845289 to
77169f5
Compare
This comment has been minimized.
This comment has been minimized.
77169f5 to
ce8d16a
Compare
This comment has been minimized.
This comment has been minimized.
b4d62d4 to
9ac9e00
Compare
This comment has been minimized.
This comment has been minimized.
9ac9e00 to
39dc3a0
Compare
|
It looks like #146972 (comment) suggests to support trailing However, if we are doing it, then I think it's time to abandon the whole " |
Semantics of trailing But what will trailing |
1d43b7d to
0eee7bc
Compare
…JonathanBrouwer Remove redundant self usages Extracted from rust-lang/rust#152996. r? petrochenkov
|
@rustbot ready |
…r=petrochenkov Print path root when printing path Extracted from rust-lang#152996. r? petrochenkov
…r=petrochenkov Print path root when printing path Extracted from rust-lang#152996. r? petrochenkov
…r=petrochenkov Print path root when printing path Extracted from rust-lang#152996. r? petrochenkov
…r=petrochenkov Print path root when printing path Extracted from rust-lang#152996. r? petrochenkov
…r=petrochenkov Print path root when printing path Extracted from rust-lang#152996. r? petrochenkov
| .map(|parent| parent.ident.name == kw::SelfLower) | ||
| .unwrap_or(false); | ||
|
|
||
| // Normalize `self::self` to `self` |
There was a problem hiding this comment.
Why? The normalization of foo::self to foo was removed, and I think we shouldn't do any other kind of "overwriting" either, only resolution.
The check is "only first and last segments can be self", and it can be checked without normalization, and self::self passes it too.
(It can be checked in one place too, now the error is split into two.)
There was a problem hiding this comment.
But use foo::self::self; will be accepted
There was a problem hiding this comment.
foo::self::self has self that is not first and not last, so it doesn't pass the check and shouldn't be accepted.
There was a problem hiding this comment.
In resolve_path_with_ribs, the path will be foo::self not foo::self::self, so the second self would be the last one when checking "only first and last segments can be self".
There was a problem hiding this comment.
use foo::self::self will have module_path = foo::self and source = self, although we have abandoned the "self rewriting" hack
0eee7bc to
bcd6516
Compare
|
@rustbot review |
This comment has been minimized.
This comment has been minimized.
|
@rustbot author |
bcd6516 to
7372043
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
View all comments
As a follow-up PR to #146972, after this PR:
selfcan appear in paths (as the consensus in Support importing path-segment keyword with renaming #146972 (comment))use ...::self [as target];will be equivalent touse ...::{self [as target]};struct S {}; use S::{self as Other};will be rejectedThis PR used to add a new lint
redundant_self, which would lintuse ...::self [as target];anduse ...::{self [as target]};, and the last commit fixes all warnings emitted by this lint.But this lint and clippy lint unnecessary_self_imports have some overlap. And
use std::io::self;is not equivalent touse std::ioin fact for now, the new lint will also cause the following known issue:So I removed this lint, and I think what it does should be done by extending the clippy lint
unnecessary_self_imports.r? petrochenkov