-
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
rustc private crates have unresolved references due to rustc_macros not being expandable #13591
Comments
It's worth noting that this seems to fail for some declarative macros and not just proc-macros as far as I can tell. It'd be nice if there were some work-around, as it makes working on out-of-tree rustc_private code a fair bit more annoying. |
Which declarative macros? That's a different issue. |
For proc macros rust-analyzer could look in the rustc sysroot for a |
Oh I didn't know those were shipped, yes we can most likely use them then. Though I guess for that we'd need to know which lib belongs to what crate, since we aren't invoking the buildscripts that mapping is foreign to us. |
For the proc macro crate rustc_macros you did look at rustc-dev contains all proc macros as rustc requires that all dependencies are available when depending on a crate, even if a dependency is a proc macro that isn't used by the current crate. |
Right that should work fine, I assumed there might be duplicate versions of some of them but that doesn't seem to be the case. |
Right, duplicate versions would be a problem. If it every happens, |
Wow, this owns, thank you! It seems that my case was a declarative macro that expanded into a proc macro (I thought I had checked that it wasn't, but I got lost in my mental expansion of it). |
Is there anything special I need to enable to make #14282 work? I'm trying to get completions or use go to definition for stuff in These are all my settings in vscode {
"rust-analyzer.inlayHints.maxLength": 40,
"rust-analyzer.inlayHints.renderColons": false,
"rust-analyzer.procMacro.attributes.enable": true,
"rust-analyzer.inlayHints.parameterHints.enable": false,
"rust-analyzer.rustc.source": "discover",
"rust-analyzer.completion.privateEditable.enable": true
} |
Ok I think I found the issue, in my laptop the names of the dynamic libraries are prefixed with
I assume some linux/mac mismatch. The following patch fixes it for me diff --git a/crates/project-model/src/build_scripts.rs b/crates/project-model/src/build_scripts.rs
index 6df1273ed..ca768ebcc 100644
--- a/crates/project-model/src/build_scripts.rs
+++ b/crates/project-model/src/build_scripts.rs
@@ -429,8 +429,9 @@ impl WorkspaceBuildScripts {
for p in rustc.packages() {
let package = &rustc[p];
if package.targets.iter().any(|&it| rustc[it].is_proc_macro) {
- if let Some((_, path)) =
- proc_macro_dylibs.iter().find(|(name, _)| *name == package.name)
+ if let Some((_, path)) = proc_macro_dylibs
+ .iter()
+ .find(|(name, _)| name == &format!("lib{}", package.name))
{
bs.outputs[p].proc_macro_dylib_path = Some(path.clone());
} |
fix: Fix rustc proc-macro handling being broken on the rustc workspace itself Also addresses #13591 (comment)
When using the
rustc_private
crates in a project (like rust-clippy for example), some things won't be resolved by r-a, because it can't expand the macros used in therustc_private
crates. The cause for that is that cargo doesn't rebuild the crates when we build the project for build-scripts and proc-macros, so we never built the necessary proc-macros, causing r-a to fall back to using the dummy expander for the relevant proc-macros.The text was updated successfully, but these errors were encountered: