Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions crates/project-model/src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,18 @@ impl Sysroot {
}

if let Some(alloc) = sysroot.by_name("alloc") {
if let Some(core) = sysroot.by_name("core") {
sysroot.crates[alloc].deps.push(core);
for dep in ALLOC_DEPS.trim().lines() {
if let Some(dep) = sysroot.by_name(dep) {
sysroot.crates[alloc].deps.push(dep)
}
}
}

if let Some(proc_macro) = sysroot.by_name("proc_macro") {
if let Some(std) = sysroot.by_name("std") {
sysroot.crates[proc_macro].deps.push(std);
for dep in PROC_MACRO_DEPS.trim().lines() {
if let Some(dep) = sysroot.by_name(dep) {
sysroot.crates[proc_macro].deps.push(dep)
}
}
}

Expand Down Expand Up @@ -239,24 +243,27 @@ fn get_rust_src(sysroot_path: &AbsPath) -> Option<AbsPathBuf> {

const SYSROOT_CRATES: &str = "
alloc
backtrace
core
panic_abort
panic_unwind
proc_macro
profiler_builtins
std
stdarch/crates/std_detect
term
test
unwind";

const ALLOC_DEPS: &str = "core";

const STD_DEPS: &str = "
alloc
core
panic_abort
panic_unwind
panic_abort
core
profiler_builtins
unwind
std_detect
term
test
unwind";
test";

const PROC_MACRO_DEPS: &str = "std";
71 changes: 14 additions & 57 deletions crates/project-model/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,10 +1566,10 @@ fn rust_project_hello_world_project_model() {
},
Dependency {
crate_id: CrateId(
1,
3,
),
name: CrateName(
"core",
"panic_unwind",
),
prelude: true,
},
Expand All @@ -1584,10 +1584,10 @@ fn rust_project_hello_world_project_model() {
},
Dependency {
crate_id: CrateId(
3,
1,
),
name: CrateName(
"panic_unwind",
"core",
),
prelude: true,
},
Expand All @@ -1602,40 +1602,31 @@ fn rust_project_hello_world_project_model() {
},
Dependency {
crate_id: CrateId(
7,
9,
),
name: CrateName(
"std_detect",
"unwind",
),
prelude: true,
},
Dependency {
crate_id: CrateId(
8,
7,
),
name: CrateName(
"term",
"std_detect",
),
prelude: true,
},
Dependency {
crate_id: CrateId(
9,
8,
),
name: CrateName(
"test",
),
prelude: true,
},
Dependency {
crate_id: CrateId(
10,
),
name: CrateName(
"unwind",
),
prelude: true,
},
],
proc_macro: Err(
"no proc macro loaded for sysroot crate",
Expand Down Expand Up @@ -1687,40 +1678,6 @@ fn rust_project_hello_world_project_model() {
),
edition: Edition2018,
version: None,
display_name: Some(
CrateDisplayName {
crate_name: CrateName(
"term",
),
canonical_name: "term",
},
),
cfg_options: CfgOptions(
[],
),
potential_cfg_options: CfgOptions(
[],
),
env: Env {
entries: {},
},
dependencies: [],
proc_macro: Err(
"no proc macro loaded for sysroot crate",
),
origin: Lang(
Other,
),
is_proc_macro: false,
},
CrateId(
9,
): CrateData {
root_file_id: FileId(
10,
),
edition: Edition2018,
version: None,
display_name: Some(
CrateDisplayName {
crate_name: CrateName(
Expand Down Expand Up @@ -1748,10 +1705,10 @@ fn rust_project_hello_world_project_model() {
is_proc_macro: false,
},
CrateId(
10,
9,
): CrateData {
root_file_id: FileId(
11,
10,
),
edition: Edition2018,
version: None,
Expand Down Expand Up @@ -1782,10 +1739,10 @@ fn rust_project_hello_world_project_model() {
is_proc_macro: false,
},
CrateId(
11,
10,
): CrateData {
root_file_id: FileId(
12,
11,
),
edition: Edition2018,
version: None,
Expand Down Expand Up @@ -1836,7 +1793,7 @@ fn rust_project_hello_world_project_model() {
},
Dependency {
crate_id: CrateId(
9,
8,
),
name: CrateName(
"test",
Expand Down