Skip to content

Commit da122a3

Browse files
committed
Merge pull request #911 from cuviper/rustup
Support either rustup or multirust environment variables
2 parents 855b292 + 11987f5 commit da122a3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,14 @@ pub fn main() {
104104
}
105105

106106
let dep_path = env::current_dir().expect("current dir is not readable").join("target").join("debug").join("deps");
107-
let sys_root = match (option_env!("MULTIRUST_HOME"), option_env!("MULTIRUST_TOOLCHAIN")) {
107+
108+
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
109+
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
110+
let sys_root = match (home, toolchain) {
108111
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
109-
_ => option_env!("SYSROOT").expect("need to specify SYSROOT env var during clippy compilation or use multirust").to_owned(),
112+
_ => option_env!("SYSROOT")
113+
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust")
114+
.to_owned(),
110115
};
111116

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

0 commit comments

Comments
 (0)