Stream: t-compiler/rust-analyzer

Topic: Errors below docs


Laurențiu (Dec 03 2020 at 09:53, on Zulip):

Should we stop returning the documentation on hover when there's a diagnostic that contains the symbol? It seems a bit heavy-handed, but it's quite annoying right now.

matklad (Dec 04 2020 at 11:26, on Zulip):

Probably? I don't use hover, so I don't have an opinion here :D

Laurențiu (Dec 04 2020 at 11:28, on Zulip):

I'm not sure what the other language servers do

Laurențiu (Dec 04 2020 at 11:29, on Zulip):

image.png

Laurențiu (Dec 04 2020 at 11:29, on Zulip):

I figured it out, the problem is that Rust docstrings are too long :smiley:

Jonas Schievink [he/him] (Dec 04 2020 at 11:30, on Zulip):

I've noticed that sometimes docs of the whole crate (every item) are displayed instead of just the thing I hover over

Jonas Schievink [he/him] (Dec 04 2020 at 13:00, on Zulip):

Example: screenshot-2020-12-04-135937.png

This is displaying much more than just the crate-level docs here: https://docs.rs/defmt/0.1.3/defmt/

Jeremy Kolb (Dec 04 2020 at 13:32, on Zulip):

yikes

Lukas Wirth (Dec 04 2020 at 14:05, on Zulip):

I think the problem here is that Use items don't have docs in the syntax representation, that is they aren't DocCommentsOwner. So I believe SourceFiles just get all the docs of those as well which causes this.

Lukas Wirth (Dec 04 2020 at 14:06, on Zulip):

I'm not 100% sure this is how this happens as I haven't checked how the parser works, but I can confirm that it's the documented use items that cause this.

Joshua Nelson (Dec 04 2020 at 14:11, on Zulip):

Not sure how to implement it, but the correct behavior is to combine the new docs with the original docs, like rustdoc does

Joshua Nelson (Dec 04 2020 at 14:12, on Zulip):

And then to show the item being re-exported, not the use itself

Jonas Schievink [he/him] (Dec 04 2020 at 14:12, on Zulip):

What happens if you put doc comments on use thing::{A, B};? Do they get combined with both A and B's docs?

Joshua Nelson (Dec 04 2020 at 14:13, on Zulip):

Uhhh good question

Jonas Schievink [he/him] (Dec 04 2020 at 14:13, on Zulip):

And does it work with glob reexports?

Joshua Nelson (Dec 04 2020 at 14:13, on Zulip):

I think rustdoc might ignore anything that's not a single import?

Joshua Nelson (Dec 04 2020 at 14:14, on Zulip):

I know for sure globs get discarded early

Joshua Nelson (Dec 04 2020 at 14:16, on Zulip):

oh interesting globs are not ignored https://github.com/rust-lang/rust/blob/master/src/librustdoc/clean/inline.rs#L132

Joshua Nelson (Dec 04 2020 at 14:17, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/librustdoc/visit_ast.rs#L251 is also relevant

Joshua Nelson (Dec 04 2020 at 14:17, on Zulip):

but I'd have to read the code to tell you any more

Lukas Wirth (Dec 04 2020 at 14:54, on Zulip):

Just checked, the parser doesn't attach the trivia tokens to Use items so the parent just inherits them as they lie inside of the parent. https://github.com/rust-analyzer/rust-analyzer/pull/6719

Lukas Wirth (Dec 04 2020 at 15:00, on Zulip):

Hmm this change doesn't play nice with folding

Last update: Jul 29 2021 at 08:30UTC