about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-12-08 16:12:37 +0000
committerGitHub <noreply@github.com>2021-12-08 16:12:37 +0000
commit020242ff0e503f650bbfe8b10866e9e22f937236 (patch)
treea58073f627f5d5df2903fbdc0121464438157947
parent86ba54c0606ca271b549c4d6738f110310de225f (diff)
parent58ce331baaeefb9a030f858dad9e56b8a7b83737 (diff)
downloadrust-020242ff0e503f650bbfe8b10866e9e22f937236.tar.gz
rust-020242ff0e503f650bbfe8b10866e9e22f937236.zip
Merge #10966
10966: fix: Fix library target overriding sysroot deps r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10827

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
-rw-r--r--crates/project_model/src/workspace.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs
index 0335f8b1746..60f99f368bd 100644
--- a/crates/project_model/src/workspace.rs
+++ b/crates/project_model/src/workspace.rs
@@ -595,6 +595,9 @@ fn cargo_to_crate_graph(
 
         // Set deps to the core, std and to the lib target of the current package
         for (from, kind) in pkg_crates.get(&pkg).into_iter().flatten() {
+            // Add sysroot deps first so that a lib target named `core` etc. can overwrite them.
+            public_deps.add(*from, &mut crate_graph);
+
             if let Some((to, name)) = lib_tgt.clone() {
                 if to != *from && *kind != TargetKind::BuildScript {
                     // (build script can not depend on its library target)
@@ -606,7 +609,6 @@ fn cargo_to_crate_graph(
                     add_dep(&mut crate_graph, *from, name, to);
                 }
             }
-            public_deps.add(*from, &mut crate_graph);
         }
     }