Auto merge of #17287 - Veykril:sysroot-encode-empty, r=Veykril · rust-lang/rust@6259991

@@ -65,7 +65,7 @@ impl WorkspaceBuildScripts {

6565

allowed_features: &FxHashSet<String>,

6666

manifest_path: &ManifestPath,

6767

toolchain: Option<&Version>,

68-

sysroot: Option<&Sysroot>,

68+

sysroot: &Sysroot,

6969

) -> io::Result<Command> {

7070

const RUST_1_75: Version = Version::new(1, 75, 0);

7171

let mut cmd = match config.run_build_script_command.as_deref() {

@@ -75,7 +75,7 @@ impl WorkspaceBuildScripts {

7575

cmd

7676

}

7777

_ => {

78-

let mut cmd = Sysroot::tool(sysroot, Tool::Cargo);

78+

let mut cmd = sysroot.tool(Tool::Cargo);

79798080

cmd.args(["check", "--quiet", "--workspace", "--message-format=json"]);

8181

cmd.args(&config.extra_args);

@@ -149,7 +149,7 @@ impl WorkspaceBuildScripts {

149149

workspace: &CargoWorkspace,

150150

progress: &dyn Fn(String),

151151

toolchain: Option<&Version>,

152-

sysroot: Option<&Sysroot>,

152+

sysroot: &Sysroot,

153153

) -> io::Result<WorkspaceBuildScripts> {

154154

let current_dir = match &config.invocation_location {

155155

InvocationLocation::Root(root) if config.run_build_script_command.is_some() => {

@@ -195,7 +195,7 @@ impl WorkspaceBuildScripts {

195195

// This is not gonna be used anyways, so just construct a dummy here

196196

&ManifestPath::try_from(workspace_root.clone()).unwrap(),

197197

None,

198-

None,

198+

&Sysroot::empty(),

199199

)?;

200200

// NB: Cargo.toml could have been modified between `cargo metadata` and

201201

// `cargo check`. We shouldn't assume that package ids we see here are

@@ -412,15 +412,15 @@ impl WorkspaceBuildScripts {

412412

rustc: &CargoWorkspace,

413413

current_dir: &AbsPath,

414414

extra_env: &FxHashMap<String, String>,

415-

sysroot: Option<&Sysroot>,

415+

sysroot: &Sysroot,

416416

) -> Self {

417417

let mut bs = WorkspaceBuildScripts::default();

418418

for p in rustc.packages() {

419419

bs.outputs.insert(p, BuildScriptOutput::default());

420420

}

421421

let res = (|| {

422422

let target_libdir = (|| {

423-

let mut cargo_config = Sysroot::tool(sysroot, Tool::Cargo);

423+

let mut cargo_config = sysroot.tool(Tool::Cargo);

424424

cargo_config.envs(extra_env);

425425

cargo_config

426426

.current_dir(current_dir)

@@ -429,7 +429,7 @@ impl WorkspaceBuildScripts {

429429

if let Ok(it) = utf8_stdout(cargo_config) {

430430

return Ok(it);

431431

}

432-

let mut cmd = Sysroot::tool(sysroot, Tool::Rustc);

432+

let mut cmd = sysroot.tool(Tool::Rustc);

433433

cmd.envs(extra_env);

434434

cmd.args(["--print", "target-libdir"]);

435435

utf8_stdout(cmd)