You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rust adapter: literal paths anchored at the workspace root (CARGO_WORKSPACE_DIR) don't become dependencies #223
A literal path in Rust code becomes a dependency on the crate it reaches. The adapter resolves it relative to the crate directory (the working directory under cargo test) and to the file's directory. But paths are also resolved relative to the workspace root:
an [env] entry with relative = true in .cargo/config.toml, such as the common CARGO_WORKSPACE_DIR = { value = "", relative = true }. [env] doesn't block, which is right.
rustc runs from the workspace root, so a proc macro that reads a relative path reads it from there.
Repro: a workspace with crates/app, crates/other and the [env] entry above. crates/app/src/lib.rs has:
#[test]fnheader(){let p = std::path::Path::new(env!("CARGO_WORKSPACE_DIR")).join("crates/other/src/lib.rs");assert!(std::fs::read_to_string(p).unwrap().starts_with("//"));}
There's no blocker and no app → other edge, so a change to other skips this test. The literal is only tried as crates/app/crates/other/... and crates/app/src/crates/other/....
Fix: also resolve each literal from the workspace root. A literal that resolves to the root itself ("/", "{}/{}", ".") is skipped, so it doesn't make every crate depend on everything. A path that only makes sense inside the crate (tests/data/input.bin) reaches nothing new in a virtual workspace.
Activity