-
Notifications
You must be signed in to change notification settings - Fork 14k
Support importing path-segment keyword with renaming #146972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mu001999
wants to merge
3
commits into
rust-lang:master
Choose a base branch
from
mu001999-contrib:fix/use-dollar-crate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
|
Failed to set assignee to
|
ehuss
reviewed
Sep 24, 2025
ehuss
added a commit
to ehuss/reference
that referenced
this pull request
Sep 24, 2025
The previous wording for this restriction was pretty confusing to me. I don't remember what I was thinking when I wrote it, and I can't find any historical explanation either. `use` paths can use `$crate` as long as they have more than one segment (`use $crate::foo` is obviously OK). I have rewritten this to make it clear it is specifically about `use $crate`. One could say that restriction is already covered by the previous point that says `use crate;` requires an `as`, but for some reason `use $crate as foo` doesn't work either. So I have left this as a separate rule for now. cc rust-lang/rust#146972 (comment) for context.
ce2578f to
49c425d
Compare
use $crate::{self} like use $crate
49c425d to
d0d3a9d
Compare
This comment has been minimized.
This comment has been minimized.
d0d3a9d to
c8526a5
Compare
This comment has been minimized.
This comment has been minimized.
c8526a5 to
db9bb42
Compare
This comment has been minimized.
This comment has been minimized.
df75a52 to
96820fa
Compare
This comment has been minimized.
This comment has been minimized.
96820fa to
1473c4c
Compare
This comment has been minimized.
This comment has been minimized.
1473c4c to
e0d5fa0
Compare
This comment has been minimized.
This comment has been minimized.
e0d5fa0 to
4c38159
Compare
This comment has been minimized.
This comment has been minimized.
4c38159 to
aca5e4e
Compare
This comment has been minimized.
This comment has been minimized.
aca5e4e to
30a19ad
Compare
This comment has been minimized.
This comment has been minimized.
30a19ad to
e181d80
Compare
This comment has been minimized.
This comment has been minimized.
e181d80 to
3ea33a4
Compare
This comment has been minimized.
This comment has been minimized.
3ea33a4 to
8b21630
Compare
This comment has been minimized.
This comment has been minimized.
8b21630 to
dad31aa
Compare
This comment has been minimized.
This comment has been minimized.
dad31aa to
e317ae4
Compare
This comment has been minimized.
This comment has been minimized.
e317ae4 to
b13c316
Compare
This comment has been minimized.
This comment has been minimized.
b13c316 to
3edfefd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6d5ea32 to
3edfefd
Compare
5113fc0 to
42a9210
Compare
use $crate::{self} like use $crate
Contributor
Author
|
@rustbot ready |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
I-lang-radar
Items that are on lang's radar and will need eventual work or consideration.
needs-fcp
This change is insta-stable, or significant enough to need a team FCP to proceed.
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference PR:
use $craterestriction reference#2010Description:
self/super/crate/$cratecan be imported with renaming nowuse self/super/crate/$crate as name;and alsouse super/crate/$crate::{self as name};use self/super/crate/$crate;and alsouse super/crate/$crate::{self};use ::self;,use ::{self};,use ::self as name;anduse ::{self as name};E0430andE0431are no longer emitted now[E0430]: self import can only appear once in an import listwas emitted before whenstd::fmt::{self, self}, but the emitted[E0252]: the name fmt is defined multiple timesis good enough[E0431]: self import can only appear in an import list with a non-empty prefixwas emiited before whenuse {self as name};, nowuse {self as name};is allowed; foruse {self};, it's denied because it lacks renaming and will emitimports need to be explicitly namedwith suggesting renaming.Fixes #146967
r? petrochenkov