-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Refactor global paths #38232
Refactor global paths #38232
Conversation
This is groundwork for hygiene 2.0, specifically hygienic global paths between crates. Since we will need the Alternatively, we could instead support hygienic global paths between crates by adding a field |
156a9b9
to
74b8d67
Compare
bcd5a06
to
47eac3f
Compare
I wanted to review this PR, but forgot, sorry. Is the intent to eliminate |
Yeah, global paths should be hygienic by default for macros 2.0, so we won't need
This refactoring will allow us to use nearly the same logic to resolve
I haven't measured it, but I don't expect this to have a significant effect on hir stats. I could instead leave hir paths unchanged and just refactor ast paths -- IIRC refactoring hir paths only caused fallout in the lowerer and pretty printer.
|
47eac3f
to
e8fe46a
Compare
☔ The latest upstream changes (presumably #38375) made this pull request unmergeable. Please resolve the merge conflicts. |
ae2f1a8
to
550b4e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with the minor refactoring
first = false | ||
} else { | ||
let mut segments = path.segments[..path.segments.len()-depth].iter(); | ||
if defaults_to_global && path.segments[0].identifier.name == keywords::CrateRoot.name() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would like an is_global
method on paths, rather than having checks like this (path.segments[0].identifier.name == keywords::CrateRoot.name()
) scattered around the code. It will also make it easier for tools using the AST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point -- will do.
try!(self.print_ident(segment.identifier)); | ||
|
||
try!(self.print_path_parameters(&segment.parameters, colons_before_params)); | ||
if segment.identifier.name != keywords::CrateRoot.name() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also for segments
e9b84d0
to
0bd6eab
Compare
☔ The latest upstream changes (presumably #38499) made this pull request unmergeable. Please resolve the merge conflicts. |
0bd6eab
to
be2a531
Compare
r = me, but you have test failures now |
be2a531
to
8a1acb2
Compare
@bors r=nrc |
📌 Commit 8a1acb2 has been approved by |
⌛ Testing commit 8a1acb2 with merge b86cb75... |
💔 Test failed - auto-mac-32-opt |
@bors retry |
This PR removes the field
global: bool
fromast::Path
andhir::Path
, instead representing a global path::foo::bar
as{{root}}::foo::bar
, where{{root}}
is a virtual keywordkeywords::CrateRoot
.Also, fixes #38016.
r? @nrc