MCPcopy Index your code
hub / github.com/Rust-API/Rust-API-Bypass-Checker / compile_time_sysroot

Function compile_time_sysroot

src/utils.rs:4–22  ·  view source on GitHub ↗

Copied from Miri Returns the "default sysroot" if no `--sysroot` flag is set. Should be a compile-time constant.

()

Source from the content-addressed store, hash-verified

2/// Returns the "default sysroot" if no `--sysroot` flag is set.
3/// Should be a compile-time constant.
4pub fn compile_time_sysroot() -> Option<String> {
5 if option_env!("RUSTC_STAGE").is_some() {
6 // This is being built as part of rustc, and gets shipped with rustup.
7 // We can rely on the sysroot computation in librustc.
8 return None;
9 }
10 // For builds outside rustc, we need to ensure that we got a sysroot
11 // that gets used as a default. The sysroot computation in librustc would
12 // end up somewhere in the build dir.
13 // Taken from PR <https://github.com/Manishearth/rust-clippy/pull/911>.
14 let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
15 let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
16 Some(match (home, toolchain) {
17 (Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
18 _ => option_env!("RUST_SYSROOT")
19 .expect("To build Miri without rustup, set the `RUST_SYSROOT` env var at build time")
20 .to_owned(),
21 })
22}

Callers 2

run_with_rustc_argsFunction · 0.85
inside_cargo_rustcFunction · 0.85

Calls 1

orMethod · 0.80

Tested by

no test coverage detected