-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Change src/etc/vscode_settings.json to always treat ./library as the sysroot source #108188
Conversation
…sysroot source See https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/False.20error.20report.20for.20.60rust-analyzer.28private-field.29.60 for further discussion; previously this had various bugs. I tested go-to-definition on: - `use std::io::Write` in `src/bootstrap/setup.rs` - `use std::cell::RefCell` in `src/librustdoc/core.rs` - `use rustc_span::symbol::sym` in `src/librustdoc/core.rs` - `use std::fmt` in `compiler/rustc_span/src/symbol.rs` - `Global` in `library/alloc/src/alloc/tests.rs` The following things still don't work: - `Global.deallocate` in alloc/tests.rs. This function is under `cfg(not(test))`, so it can't be enabled without disabling RA in `tests.rs` altogether. I think this might be fixable by moving `library/alloc/src/alloc/tests.rs` to `library/alloc/tests/alloc/lib.rs`, so it's in a different crate, but I'd like to avoid blocking this improvement on that change.
Failed to set assignee to
|
r? bootstrap - I feel pretty confident this is better than the status quo, but happy to make further improvements. |
cc @ozkanonur |
I can't properly test this since I am not using Vscode. Are you using vscode? @albertlarsan68 |
Yes I do. |
@ozkanonur what editor are you using? There's instructions for how to use this with neovim on https://rustc-dev-guide.rust-lang.org/building/suggested.html#neovim |
I am using neovim, but without the |
Ah, gotcha. Maybe we should rename that file to |
Sure, I think it's better naming for that file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the notes you mentioned works like charm(I also tested go to reference) with this change. Plus, before this change, when I open compiler/rustc_attr/src/session_diagnostics.rs
I had the following error from nvim lsp:
LSP[rust_analyzer] rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /home/nimda/devspace/personal/rust/src/bootstrap/Cargo.toml.: can't load standard library from sysroot /ho
me/nimda/devspace/personal/rust/./build/host/stage0-sysroot
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /home/nimda/devspace/personal/rust/Cargo.toml.: can't load standard library from sysroot /home/nimda/devspace/personal/rust/.
/build/host/stage0-sysroot
And also Diagnostic
was showing error proc macro `Diagnostic` not expanded: crate has not (yet) been built
This change fixes it. The error no longer exists, and Diagnostic
doesn't show error. I can use signature help to get information about it, and also use go to definition on it.
Do you want to rename the file in this PR, or in another? |
Let's do a follow-up, it ended up being slightly more complicated than I expected and I want to land this change since it works well :) @bors r=albertlarsan68 |
@bors rollup |
…llaumeGomez Rollup of 5 pull requests Successful merges: - rust-lang#107766 (Fix json reexports of different items with same name) - rust-lang#108129 (Correctly handle links starting with whitespace) - rust-lang#108188 (Change src/etc/vscode_settings.json to always treat ./library as the sysroot source) - rust-lang#108203 (Fix RPITITs in default trait methods (by assuming projection predicates in param-env)) - rust-lang#108212 (Download rustfmt regardless of rustc being set in config.toml) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Be aware that when the filename changes, some of the editors won't be able to detect this file and they will require some additional configurations. |
The rename is about the checked in file ( |
Ah right, I confused it with |
This rename means that the file may be used with others editors than VS Code. |
The file can already be used with other editors. This is just about making the name less confusing in review. |
See
https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/False.20error.20report.20for.20.60rust-analyzer.28private-field.29.60 for further discussion; previously this had various bugs.
I tested go-to-definition on:
use std::io::Write
insrc/bootstrap/setup.rs
use std::cell::RefCell
insrc/librustdoc/core.rs
use rustc_span::symbol::sym
insrc/librustdoc/core.rs
use std::fmt
incompiler/rustc_span/src/symbol.rs
Global
inlibrary/alloc/src/alloc/tests.rs
The following things still don't work:
Global.deallocate
in alloc/tests.rs. This function is undercfg(not(test))
, so it can't be enabled without disabling RA intests.rs
altogether. I think this might be fixable by movinglibrary/alloc/src/alloc/tests.rs
tolibrary/alloc/tests/alloc/lib.rs
, so it's in a different crate, but I'd like to avoid blocking this improvement on that change.cc @thomcc @BoxyUwU @spastorino - you've had issues with RA in the past, does this fix them? Are there any other use cases I should test? You can try these changes out by running
cp src/etc/vscode_settings.json .vscode/settings.json
, or runningx setup
and picking a random profile (it won't overwrite config.toml if it already exists). See #108135 for plans to make updating the config easier.r? @Veykril