Skip to content

Commit c170aa2

Browse files
committed
Merge pull request #915 from Manishearth/sysroot
Use rustc --print sysroot, bump to v66 r? @llogiq
2 parents f966778 + 03a309d commit c170aa2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.65"
3+
version = "0.0.66"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc::session::{config, Session};
1717
use rustc::session::config::{Input, ErrorOutputType};
1818
use syntax::diagnostics;
1919
use std::path::PathBuf;
20+
use std::process::Command;
2021

2122
struct ClippyCompilerCalls(RustcDefaultCalls);
2223

@@ -109,9 +110,14 @@ pub fn main() {
109110
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
110111
let sys_root = match (home, toolchain) {
111112
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
112-
_ => option_env!("SYSROOT")
113-
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust")
114-
.to_owned(),
113+
_ => option_env!("SYSROOT").map(|s| s.to_owned())
114+
.or(Command::new("rustc").arg("--print")
115+
.arg("sysroot")
116+
.output().ok()
117+
.and_then(|out| String::from_utf8(out.stdout).ok())
118+
.map(|s| s.trim().to_owned())
119+
)
120+
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"),
115121
};
116122

117123
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {

0 commit comments

Comments
 (0)