- Notifications
You must be signed in to change notification settings - Fork 14.1k
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
base: main
Are you sure you want to change the base?
Conversation
| Failed to set assignee to
|
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.
5e934e3 to a200261 Compare | @rustbot ready |
a200261 to 3c4b5af Compare | @rustbot ready |
| Thanks! |
This comment has been minimized.
This comment has been minimized.
Support importing path-segment keyword with renaming
| @craterbot check |
| 👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
| @petrochenkov Thanks a ton! I appreciate you taking the time to review this. |
| ☔ The latest upstream changes (presumably #149462) made this pull request unmergeable. Please resolve the merge conflicts. |
3c4b5af to c8f12de 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. |
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 #29036
Fixes #35612
Fixes #37156
Fixes #146967
r? petrochenkov