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 the visibility of an item #79

Closed
euclio opened this issue Jul 27, 2017 · 3 comments
Closed

Provide an API to get the visibility of an item #79

euclio opened this issue Jul 27, 2017 · 3 comments

Comments

@euclio
Copy link
Contributor

euclio commented Jul 27, 2017

I'm not sure if this issue is better suited here or rust-lang/rust, as I'm not sure if this information is in the analysis data.

This is required for steveklabnik/rustdoc, so we can only document public items.

cc steveklabnik/rustdoc#7

@nrc
Copy link
Member

nrc commented Jul 27, 2017

By using a config (see https://github.com/nrc/rls-data/blob/master/src/config.rs) you can request only public items from save-analysis. I think this solves your problem without needing visibility in the analysis data. However, I think it is not quite what you want - you want 'visible' items, not public ones (i.e., a public item in a non-public module should not be included). This needs fixing in the save-analysis crate of the compiler. (I think you may also need to take into account pub use, which is a bit more complicated).

So, why not include visibility info in save-analysis? Basically because it is usually not what you want, you want to know whether an item is visible from a certain place in the code, and the pub annotation is not enough to tell you that - you need the modules, plus the algorithm used. IMO that should stay in the compiler. Given that the answer depends on 'where it is asked' it seems like not a suitable thing to have in save-analysis (also, it is something that IDEs never use).

bors added a commit to rust-lang/rust that referenced this issue Nov 23, 2017
Allow filtering analysis by reachability

Fixes #43521.
Fixes rust-dev-tools/rls-analysis#79.

This PR allows a user to filter items present in the save-analysis data by setting the `reachable_only` config option. This option is intended for use by the new rustdoc. The PR isn't quite finished, because it's dependent on a new release of rls-data, but I want to make sure that the approach is valid.

rust-dev-tools/rls-analysis#79 mentions that `pub use` might need to be handled, but my thinking is that the consumer of the analysis data would be able to infer which imports are `pub use`, and which items are only reachable through `pub use`, so that doesn't need to be handled here.

r? @nrc
@steveklabnik
Copy link
Contributor

steveklabnik commented Nov 28, 2017

rust-lang/rust#43521 was fixed five days ago, so this should be unblocked? This bug is still important for new-rustdoc.

@euclio
Copy link
Contributor Author

euclio commented Nov 28, 2017

Yep, this should be closed.

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

3 participants