mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Don't load auxiliary crates outside the workspace
This commit is contained in:
parent
ac8806df08
commit
22ea5595a8
1 changed files with 9 additions and 0 deletions
|
@ -574,6 +574,15 @@ fn cargo_to_crate_graph(
|
||||||
has_private |= cargo[pkg].metadata.rustc_private;
|
has_private |= cargo[pkg].metadata.rustc_private;
|
||||||
let mut lib_tgt = None;
|
let mut lib_tgt = None;
|
||||||
for &tgt in cargo[pkg].targets.iter() {
|
for &tgt in cargo[pkg].targets.iter() {
|
||||||
|
if cargo[tgt].kind != TargetKind::Lib && !cargo[pkg].is_member {
|
||||||
|
// For non-workspace-members, Cargo does not resolve dev-dependencies, so we don't
|
||||||
|
// add any targets except the library target, since those will not work correctly if
|
||||||
|
// they use dev-dependencies.
|
||||||
|
// In fact, they can break quite badly if multiple client workspaces get merged:
|
||||||
|
// https://github.com/rust-analyzer/rust-analyzer/issues/11300
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(file_id) = load(&cargo[tgt].root) {
|
if let Some(file_id) = load(&cargo[tgt].root) {
|
||||||
let crate_id = add_target_crate_root(
|
let crate_id = add_target_crate_root(
|
||||||
&mut crate_graph,
|
&mut crate_graph,
|
||||||
|
|
Loading…
Reference in a new issue