-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rustc: remove unnecessary extern_prelude logic from ty::item_path. #56655
Conversation
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.
Do we want some sort of test?
r=me with the comments + (ideally) a test
direct: true, | ||
span, | ||
.. | ||
}) if !span.is_dummy() => { |
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 a comment would be good here -- it's pretty non-obvious what's going on.
.. | ||
}) => { | ||
debug!("try_push_visible_item_path: def_id={:?}", def_id); | ||
self.push_item_path(buffer, def_id, pushed_prelude_crate); | ||
if !span.is_dummy() { |
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.
Similarly, comment here -- or maybe we can pull this into some kind of common helper function with the code above?
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.
So in a different branch I was able to deduplicate this by moving the local mode logic from push_krate_path
to try_push_visible_item_path
and relying on the fact that try_push_visible_item_path
can override the behavior of push_item_path
. But maybe we can avoid the dummy span check here by some other means.
I guess that this means that if you have an |
@nikomatsakis You will get whatever is preferred by the rest of the system, likely the |
@eddyb I'm not sure what exactly |
@petrochenkov That's perhaps useful, but what's needed here is something tied to the rust/src/librustc_metadata/creader.rs Line 382 in 4c0116e
And its calls in that module, e.g.: rust/src/librustc_metadata/creader.rs Lines 1054 to 1064 in 4c0116e
Right now we track what caused a crate to be loaded, which used to always be an We should instead record whether the crate can be referred to by name (and specifically by which name), or that we have to spell out the path to an
(random aside, |
Then |
@eddyb @petrochenkov -- I can't quite tell what's the status of this PR. I wrote r=me above, modulo testing. Do we think we want to alter the behavior in this case, though?
|
Relevant issue - #55779 (infinite recursion in While printing the trait |
I'm just going to change this to r? @petrochenkov =) |
Ping from triage @petrochenkov : This PR requires your review. |
This PR requires eddyb's return. |
Ping from triage @eddyb: What is the status of this PR? |
This seems to be included into #57967 |
Right, I made this PR while starting work on the refactoring #57967 is based on. IIRC, @nikomatsakis' comments are addressed in that, by moving the "relative extern crate path" logic into the "visible path" part of path printing (since they're somewhat related). Do you still want to do #56655 (comment), before landing #57967, or can it wait? |
☔ The latest upstream changes (presumably #58151) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage @eddyb any updates on this? |
ping from triage @eddyb |
Needs a rebase here. |
Closing this due to inactivity after a discussion with the author. |
The checks added in 02357e4 effectively turned
crate::std
intostd
, but they were too general (affecting anycrate::foo
wherefoo
was in the extern prelude, not just extern crates), and unnecessary, as only theextern crate
s created by "std
injection" need any special-casing.I've replaced the check for an extern prelude name with not printing the full path to an
extern crate
if thespan
inside themiddle::cstore::ExternCrate
is a dummy one.Since this only affects the user-facing "relative" mode, it shouldn't have interactions with linking, and the only observable effect should be sometimes-shorter paths in diagnostics.
r? @nikomatsakis cc @davidtwco