Skip to content
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

Closed
wants to merge 2 commits into from
Closed

WIP: Save path segments #53983

wants to merge 2 commits into from

Conversation

nrc
Copy link
Member

@nrc nrc commented Sep 6, 2018

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, from resolve_crate, and I think that is the only time I would record the path segments (i.e., I wouldn't when calling resolve_import because record_used is false).

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

@rust-highfive
Copy link
Collaborator

r? @oli-obk

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 6, 2018
});
source.name = crate_name;
span: source.0.span,
}, Some(ast::CRATE_NODE_ID)));
Copy link
Member Author

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

@nrc nrc unassigned oli-obk Sep 6, 2018
@nrc nrc added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 6, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Sep 6, 2018

I'm getting path resolved multiple times

Do you have more details? Is that happening on the last segment?

@petrochenkov petrochenkov self-assigned this Sep 6, 2018
@nrc
Copy link
Member Author

nrc commented Sep 6, 2018

@nrc
Copy link
Member Author

nrc commented Sep 7, 2018

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

@eddyb
Copy link
Member

eddyb commented Sep 7, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants