Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

Provide an API to get imports, particularly pub use #123

Closed
euclio opened this issue Nov 19, 2017 · 5 comments
Closed

Provide an API to get imports, particularly pub use #123

euclio opened this issue Nov 19, 2017 · 5 comments

Comments

@euclio
Copy link
Contributor

euclio commented Nov 19, 2017

This is needed for the new rustdoc. Right now it is possible to get defs that are exported through pub use, but we have no way to distinguish them from naturally exported items.

Ideally rustdoc would be able to get all defs and imports, and by looping through the imports, determine if the import is an export or a re-export of a given def.

What should the API for this look like?

@nrc
Copy link
Member

nrc commented Nov 19, 2017

What exactly does Rustdoc need to know here? How does it use the info and why does it need to distinguish between an export and a re-export?

@euclio
Copy link
Contributor Author

euclio commented Nov 19, 2017

The new rustdoc needs to be able to create links to a given Def at all paths that the Def is accessible through, including pub uses.

Currently, the new rustdoc works by recursively traversing the crate root Def and its children. Assuming that we are able to filter analysis data by reachability, it doesn't find any Defs that have a non-exported Def in their ancestry. However, these Defs might be exported through a pub use. rustdoc needs to link the Def at the path it's exported through. If a Def is accessible through multiple paths, rustdoc needs to indicate that those paths are re-exports of the other path.

I'm not sure that rls-analysis needs to distinguish between exports and re-exports (the client could probably infer it), but the new rustdoc certainly needs to display the two differently, like the current rustdoc does.

@euclio
Copy link
Contributor Author

euclio commented Dec 2, 2017

@nrc I realize that imports are already recorded in the analysis data, but I'm confused how to get the path that the import is at. I'm guessing rls-data/the compiler will have to be modified to include qualname or a similar field in an Import?

@nrc
Copy link
Member

nrc commented Dec 3, 2017

I would rather add a parent field than a qualname one - qualname has been irritating in the past and I think a parent gives the required data.

bors added a commit to rust-lang/rust that referenced this issue Dec 15, 2017
save-analysis: add parents to imports

This PR populates the `parent` field added to `Import` in `rls-data` 0.14.

I'm not quite sure if I handled nested imports' parents correctly: this is a new feature to me.

r? @nrc

cc rust-dev-tools/rls-analysis#123
@euclio
Copy link
Contributor Author

euclio commented Jan 12, 2019

I'm going to close this, as the upstream project (rustdoc2) is dormant.

@euclio euclio closed this as completed Jan 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants