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

rust-analyzer can't get data on rustc internals #3517

Closed
matthiaskrgr opened this issue Mar 8, 2020 · 4 comments
Closed

rust-analyzer can't get data on rustc internals #3517

matthiaskrgr opened this issue Mar 8, 2020 · 4 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@matthiaskrgr
Copy link
Member

When using rust-analyzer on clippy for example, it seems to fail to get a lot of info on functions/types that come from rustc, for example:

#![feature(rustc_private)]
extern crate rustc_lint;

pub fn register_pre_expansion_lints(_store: &mut rustc_lint::LintStore) {}

fn main() {}

Hovering rustc_lint::LintStore did not provide any type information.

I tried the same with the clippy submodule inside the rustc-repo hoping that could solve it but to no avail.

@flodiebold
Copy link
Member

I think rustc_lint comes from the sysroot here, right? But it isn't included in the rust-src component, so we don't have the source. You could try overriding the dependency in Cargo.toml with a path dependency that points to the source 🤔

@bjorn3
Copy link
Member

bjorn3 commented Mar 8, 2020

The rustc crate is included in rust-src, but many other rustc private crates aren't.

@matthiaskrgr
Copy link
Member Author

You could try overriding the dependency in Cargo.toml with a path dependency that points to the source thinking

[dependencies]
rustc_lint = { path = "/home/matthias/vcs/github/rust/src/librustc_lint"}

makes it work indeed! 👍

matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue May 27, 2020
This crate takes am absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

cc rust-lang/rust-analyzer#3517
cc rust-lang#5514
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue May 27, 2020
This crate takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: ./souce_injector/target/debug/souce_injector /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc rust-lang#5514
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue May 27, 2020
This crate takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: ./source_injector/target/debug/souce_injector /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc rust-lang#5514
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue May 28, 2020
This takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc rust-lang#5514
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue May 28, 2020
This takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc rust-lang#5514
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this issue May 28, 2020
This takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc rust-lang#5514
bors added a commit to rust-lang/rust-clippy that referenced this issue May 28, 2020
cargo_dev: add ra_setup

It takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc #5514

changelog: none
bors added a commit to rust-lang/rust-clippy that referenced this issue May 31, 2020
cargo_dev: add ra-setup

It takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc rust-lang/rust-analyzer#3517
cc #5514

changelog: none
@flip1995
Copy link
Member

After rust-lang/rust#76856, this could be done with implementing https://github.com/rust-analyzer/rust-analyzer/blob/96e988fcc3be11acc89dc2c1957bc14e8f39c911/crates/project_model/src/sysroot.rs#L108 for $(rustc --print sysroot)/lib/rustlib/rustc-src/rust/compiler, IIUC.

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Jan 22, 2021
bnjbvr added a commit to bnjbvr/rust-analyzer that referenced this issue Feb 11, 2021
If the configured rustcSource was not set, then try to automatically
detect a source for the sysroot rustc directory.
bnjbvr added a commit to bnjbvr/rust-analyzer that referenced this issue Feb 11, 2021
If the configured rustcSource was not set, then try to automatically
detect a source for the sysroot rustc directory.
bnjbvr added a commit to bnjbvr/rust-analyzer that referenced this issue Feb 13, 2021
).

If the configured rustcSource is set to "discover", try to automatically
detect a source from the sysroot rustc directory.
bors bot added a commit that referenced this issue Feb 14, 2021
7643: Automatically detect the rustc-src directory (fixes #3517) r=matklad a=bnjbvr

If the configured rustcSource was not set, then try to automatically
detect a source for the sysroot rustc directory.

I wasn't sure how to do it in the case of the project.json file, though.

7663: Tolerate spaces in nix binary patching r=matklad a=CertainLach

If path to original file contains space (I.e on code insiders, where
default data directory is ~/Code - Insiders/), then there is syntax
error evaluating src arg.

Instead pass path as str, and coerce to path back in nix expression

Co-authored-by: Benjamin Bouvier <[email protected]>
Co-authored-by: Yaroslav Bolyukin <[email protected]>
@bors bors bot closed this as completed in 4a6e602 Feb 14, 2021
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

5 participants