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

Modules in paths are highlighted inconsistently #6842

Closed
jyn514 opened this issue Dec 12, 2020 · 14 comments
Closed

Modules in paths are highlighted inconsistently #6842

jyn514 opened this issue Dec 12, 2020 · 14 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@jyn514
Copy link
Member

jyn514 commented Dec 12, 2020

image

ast:: is two different colors; it should be the same in both (maybe green is correct?).

https://github.com/rust-lang/rust/blob/c3ed6681ff8d446e68ce272be4bf66f4145f6e29/src/librustdoc/clean/types.rs#L620-L628

@lnicola
Copy link
Member

lnicola commented Dec 20, 2020

I can't reproduce this outside of rustc.

What do you get if you choose "Inspect Editor Tokens and Scopes" and move the cursor over the two ast instances?

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Dec 20, 2020
@jyn514
Copy link
Member Author

jyn514 commented Dec 20, 2020

What do you get if you choose "Inspect Editor Tokens and Scopes"

This hangs for me. How long does it normally take? It's been over three minutes.

@jyn514
Copy link
Member Author

jyn514 commented Dec 20, 2020

@lnicola
Copy link
Member

lnicola commented Dec 20, 2020

It should be instantaneous. It shows a pop-up with highlight information, without even calling into the LSP server.

@jyn514
Copy link
Member Author

jyn514 commented Dec 20, 2020

Well it is definitely not instantaneous for me 😆 in case it matters, I'm using VSCode Remote-SSH.

@jyn514
Copy link
Member Author

jyn514 commented Dec 20, 2020

in case it matters, I'm using VSCode Remote-SSH.

this is unrelated, it works on a different project, just not rust-lang/rust.

@lnicola
Copy link
Member

lnicola commented Dec 20, 2020

I think @jonas-schievink might be able to test this.

@jonas-schievink
Copy link
Contributor

Can reproduce. None of the ast tokens resolve correctly for me. In fact, none of the extern crates in librustdoc resolve. Is that the issue here? Do I have to do anything special for that to work, @jyn514?

(naturally, all tokens in the from_ast function header types are of type unresolvedReference, and the inconsistent colors are due to the textmate grammar)

The output panel contains this, normally this only breaks paths to libcore, but maybe it decided to break rustc crates this time:

[ERROR project_model::workspace] cyclic deps: cargo_test_support(CrateId(160)) -> cargo(CrateId(144))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1142)) -> core(CrateId(226))
[ERROR project_model::workspace] cyclic deps: wasi(CrateId(1664)) -> rustc_std_workspace_alloc(CrateId(1141))

This is on rust-lang/rust@1e88a17 with rust-analyzer 2020-12-14.

@jyn514
Copy link
Member Author

jyn514 commented Dec 21, 2020

In fact, none of the extern crates in librustdoc resolve.

Ahh, that's probably it - those crates are loaded from the sysroot, not from cargo. Didn't rust-analyzer add support for rustc_private recently? Or am I misremembering? If it helps, you don't need to use the toolchain directly (and it would be hard because it's a stage 1 build), you can just look at the sources in compiler/.

@jonas-schievink
Copy link
Contributor

Oh, yeah, if they're from the sysroot then that explains it. I'm not sure how our support looks there.

@jonas-schievink
Copy link
Contributor

This can be fixed by setting "rust-analyzer.rustcSource": "./Cargo.toml", in the rust-lang/rust workspace. I don't think that's the correct path, but stage0 does not download rustc-src, so you'd have to manually install the beta compiler and point it there.

Closing as fixed in any case!

@jyn514
Copy link
Member Author

jyn514 commented Aug 16, 2021

I don't think that's the correct path, but stage0 does not download rustc-src, so you'd have to manually install the beta compiler and point it there.

That seems wrong, it should use the in-tree sources, not the sources of the beta compiler. I think ./Cargo.toml is correct.

Thanks for the workaround :) I'll add this to the dev-guide.

@jyn514
Copy link
Member Author

jyn514 commented Aug 16, 2021

That seems wrong, it should use the in-tree sources, not the sources of the beta compiler. I think ./Cargo.toml is correct.

Err, I guess it depends if it's building with stage 0 or stage 1. But I doubt there's any way to get rust-analyzer to know about both, so hard-coding stage1 seems fine, that's the one download-rustc uses and what I'd expect most rustdoc contributors to be using.

@jyn514
Copy link
Member Author

jyn514 commented Aug 16, 2021

Err, I guess it depends if it's building with stage 0 or stage 1.

Wait no, I was right the first time. The sysroot for stage 0 tools is newly built compiler. https://github.com/rust-lang/rust/blob/2bd17c1d43bba43412cc2f051323a279d6751e43/src/bootstrap/builder.rs#L1080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

3 participants