Skip to content

Commit 2826eb5

Browse files
committed
Don't build dependencies when retrieving target data layout
`cargo rustc -- <args>` first builds dependencies then calls `rustc <args>` for the current package. Here, we don't want to build dependencies, we just want to call `rustc --print`. An unstable `cargo rustc` `--print` command bypasses building dependencies first. This speeds up execution of this code path and ensures RA doesn't recompile dependencies with the `RUSTC_BOOTSRAP=1` env var flag set. Note that we must pass `-Z unstable-options` twice, first to enable the `cargo` unstable `--print` flag, then later to enable the unstable `rustc` `target-spec-json` print request.
1 parent 344a79c commit 2826eb5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/project-model/src/target_data_layout.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ pub fn get(
3232
Sysroot::set_rustup_toolchain_env(&mut cmd, sysroot);
3333
cmd.envs(extra_env);
3434
cmd.current_dir(cargo_toml.parent())
35-
.args(["rustc", "--", "-Z", "unstable-options", "--print", "target-spec-json"])
35+
.args([
36+
"rustc",
37+
"-Z",
38+
"unstable-options",
39+
"--print",
40+
"target-spec-json",
41+
"--",
42+
"-Z",
43+
"unstable-options",
44+
])
3645
.env("RUSTC_BOOTSTRAP", "1");
3746
if let Some(target) = target {
3847
cmd.args(["--target", target]);

0 commit comments

Comments
 (0)