-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
rust-analyzer version: rust-analyzer version: 0.3.2188-standalone [/home/bjorn/.vscode/extensions/rust-lang.rust-analyzer-0.3.2188-linux-x64/server/rust-analyzer]
rustc version: rustc 1.82.0 (f6e511eec 2024-10-15)
editor or extension: VSCode
relevant settings:
{
"rust-analyzer.cargo.allTargets": false
}
repository link (if public, optional): (eg. rust-analyzer)
code snippet to reproduce:
#- Cargo.toml
[package]
name = "rust_analyzer_reproducer"
version = "0.1.0"
edition = "2021"
[dev-dependencies]
serde = { version = "1.0.215", features = ["derive"] }
//- tests/foo.rs
#[derive(serde::Serialize)]
struct Foo;
and then after rust-analyzer has started make any change to struct Foo;
. This will result in a "proc-macro crate build data is missing dylib path" error. This doesn't make it clear that this is because disabling --all-targets
prevents serde_derive
from getting built as it is a dev-dependency. It also shouldn't show up as an error, but closer to the diagnostic that is shown when build script building is disabled entirely though preferably also explaining why the proc-macro wasn't built.
Activity
ChayimFriedman2 commentedon Nov 18, 2024
I'm not sure how we could detect that if
--all-targets
will be enabled the proc macro will be available. The downgrade in severity is possible, though.bjorn3 commentedon Nov 18, 2024
We can detect that the proc macro dependency is a dev-dependency, right? All proc macros that are only reachable through a dev-dependency edge in the dependency graph are only available when
--all-targets
or similar is passed.ChayimFriedman2 commentedon Nov 18, 2024
I don't think we can detect that, we don't know about dev dependencies, only about dependencies in the current configuration. Maybe we can add this but I don't know if this information is available to us from Cargo.
bjorn3 commentedon Nov 18, 2024
cargo metadata
most certainly reports dev-dependencies. Otherwise rust-analyzer wouldn't even know to expect a proc macro here and thus complain about missing data for the proc macro. Not setting--all-targets
only causes thecargo check
invocation that rust-analyzer does to run build script amd build proc macro to omit artifact notifications for proc macros that are dev-dependencies.Veykril commentedon Dec 2, 2024
Our HIR layer doesn't know about dev dependencies (intentionally) iirc
jerusdp commentedon Jan 14, 2025
If you are loading the dependencies from a workspace you don't know whether how they are used.
Veykril commentedon Jul 3, 2025
I think thanks to
--compile-time-deps
we can ignore that setting for build scripts entirely and always pass--all-targets
. We never try to build artifacts that may not built for the target with that flag anyways: #20159