Skip to content

Commit 6cbd2d3

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3569,10 +3569,17 @@ 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+
35723577
let registry_path = cargo_home.join("registry").join("src");
35733578
let toolchain_path = rustup_home.join("toolchains");
35743579

3575-
path.starts_with(&registry_path) || path.starts_with(&toolchain_path)
3580+
path.starts_with(&registry_path)
3581+
|| path.starts_with(&toolchain_path)
3582+
|| sysroot.as_ref().map_or(false, |sr| path.starts_with(sr))
35763583
} else {
35773584
false
35783585
}

0 commit comments

Comments
 (0)