-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
docs: explain how to get code completion to work when hacking on clippy #5514
Comments
likely relevant: rust-lang/rust-analyzer#3517 (comment) |
another one: intellij-rust/intellij-rust#1618 |
My current workaround is to redirect all the rustc dep paths to respective absolute paths to my rustc-repo. This blows up compiletime since I need to build 70% of rustc now but it makes rust-analyzer find rustc sources for analysis :) diff --git a/Cargo.toml b/Cargo.toml
index 6999b6bd..027749c0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,6 +35,11 @@ semver = "0.9"
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
tempfile = { version = "3.1.0", optional = true }
lazy_static = "1.0"
+# make rustc deps visible to rust analyzer
+rustc_driver = { path = "/home/matthias/vcs/github/rust/src/librustc_driver" }
+rustc_errors = { path = "/home/matthias/vcs/github/rust/src/librustc_errors" }
+rustc_interface = { path = "/home/matthias/vcs/github/rust/src/librustc_interface" }
+rustc_middle = { path = "/home/matthias/vcs/github/rust/src/librustc_middle" }
[dev-dependencies]
cargo_metadata = "0.9.0"
diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml
index 1c0be727..4f8b7e62 100644
--- a/clippy_lints/Cargo.toml
+++ b/clippy_lints/Cargo.toml
@@ -33,5 +33,28 @@ semver = "0.9.0"
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
url = { version = "2.1.0", features = ["serde"] }
+# make rustc deps visible to rust analyzer
+fmt_macros = { path = "/home/matthias/vcs/github/rust/src/libfmt_macros" }
+rustc_ast = { path = "/home/matthias/vcs/github/rust/src/librustc_ast" }
+rustc_ast_pretty = { path = "/home/matthias/vcs/github/rust/src/librustc_ast_pretty" }
+rustc_attr = { path = "/home/matthias/vcs/github/rust/src/librustc_attr" }
+rustc_data_structures = { path = "/home/matthias/vcs/github/rust/src/librustc_data_structures" }
+rustc_driver = { path = "/home/matthias/vcs/github/rust/src/librustc_driver" }
+rustc_errors = { path = "/home/matthias/vcs/github/rust/src/librustc_errors" }
+rustc_hir = { path = "/home/matthias/vcs/github/rust/src/librustc_hir" }
+rustc_hir_pretty = { path = "/home/matthias/vcs/github/rust/src/librustc_hir_pretty" }
+rustc_index = { path = "/home/matthias/vcs/github/rust/src/librustc_index" }
+rustc_infer = { path = "/home/matthias/vcs/github/rust/src/librustc_infer" }
+rustc_lexer = { path = "/home/matthias/vcs/github/rust/src/librustc_lexer" }
+rustc_lint = { path = "/home/matthias/vcs/github/rust/src/librustc_lint" }
+rustc_middle = { path = "/home/matthias/vcs/github/rust/src/librustc_middle" }
+rustc_mir = { path = "/home/matthias/vcs/github/rust/src/librustc_mir" }
+rustc_parse = { path = "/home/matthias/vcs/github/rust/src/librustc_parse" }
+rustc_session = { path = "/home/matthias/vcs/github/rust/src/librustc_session" }
+rustc_span = { path = "/home/matthias/vcs/github/rust/src/librustc_span" }
+rustc_target = { path = "/home/matthias/vcs/github/rust/src/librustc_target" }
+rustc_trait_selection = { path = "/home/matthias/vcs/github/rust/src/librustc_trait_selection" }
+rustc_typeck = { path = "/home/matthias/vcs/github/rust/src/librustc_typeck" }
+
[features]
deny-warnings = [] |
Why don't you use upstream libs? |
Looks like there is no component that actually supplies the rustc source code (only libcore/liballoc/libstc etc) |
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
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
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
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
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
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
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
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
There have been several people in discord now asking how to get code-completion for rustc code when working on clippy code.
We should see if we can figure something out that works (using rust-analyzer?) and perhaps have some kind of guideline for getting it running for everyone, similar to the "how to get the rustc-master toolchain" section in the contribution guide. https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#fixing-build-failures-caused-by-rust
The text was updated successfully, but these errors were encountered: