Skip to content

Commit 6325b45

Browse files
committed
Add support for rustc sysroot
Signed-off-by: xizheyin <[email protected]>
1 parent 6b0c39e commit 6325b45

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

compiler/rustc_errors/src/emitter.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -3569,10 +3569,18 @@ fn is_external_library(sm: &SourceMap, span: Span) -> bool {
35693569
}
35703570
};
35713571

3572+
let sysroot = match std::env::var("RUSTC_SYSROOT") {
3573+
Ok(dir) => Some(std::path::PathBuf::from(dir)),
3574+
Err(_) => None,
3575+
};
3576+
3577+
println!("sysroot: {:?}", sysroot);
35723578
let registry_path = cargo_home.join("registry").join("src");
35733579
let toolchain_path = rustup_home.join("toolchains");
35743580

3575-
path.starts_with(&registry_path) || path.starts_with(&toolchain_path)
3581+
path.starts_with(&registry_path)
3582+
|| path.starts_with(&toolchain_path)
3583+
|| sysroot.as_ref().map_or(false, |sr| path.starts_with(sr))
35763584
} else {
35773585
false
35783586
}

0 commit comments

Comments
 (0)