-
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
WIP: Save path segments #53983
WIP: Save path segments #53983
Conversation
r? @oli-obk (rust_highfive has picked a reviewer for you, use r? to override) |
}); | ||
source.name = crate_name; | ||
span: source.0.span, | ||
}, Some(ast::CRATE_NODE_ID))); |
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.
This should be a fresh node id, I think, but the id that is getting multiply resolved is not CRATE_NODE_ID
Do you have more details? Is that happening on the last segment? |
ca5cde0
to
deac165
Compare
I figured out what was going wrong - when resolving a nested import, we were using the same path prefix, rather than cloning, which was fine before, but now the segments would be resolved multiple times |
@nrc Ouch. If we don't hack around it, we could probably use it as a start of a redesign of how imports are resolved, to only resolve the prefix once, and then have the nested imports depend on the prefix import. |
DON'T LAND
The idea with this PR is to save a def for every element of a path (we currently know this in name resolution but don't save it). Then we can save it in save-analysis and in an IDE we will be able to jump from the prefix segments of a path to their definition (which is a glaring omission in the RLS right now).
Obviously this is missing the save-analysis parts.
However, I am stuck because the compiler is panicking when bootstrapping std. I'm getting
path resolved multiple times
from here. From backtraces this is happening when resolving imports, (finalize_import
is in the backtrace). However, it looks like that is only called once, fromresolve_crate
, and I think that is the only time I would record the path segments (i.e., I wouldn't when callingresolve_import
becauserecord_used
isfalse
).So, questions - am I doing anything stupid here which I shouldn't be doing at all or should be doing differently? Or do you know/can you see any way which we could be resolving the path segments more than once?
cc @petrochenkov @eddyb @jseyfried