mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
Build sys_root in driver with PathBuf instead of String
This commit is contained in:
parent
6b8ebcc0c8
commit
c100c70822
1 changed files with 14 additions and 6 deletions
|
@ -12,7 +12,7 @@ extern crate rustc_plugin;
|
||||||
use rustc_interface::interface;
|
use rustc_interface::interface;
|
||||||
use rustc_tools_util::*;
|
use rustc_tools_util::*;
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{exit, Command};
|
use std::process::{exit, Command};
|
||||||
|
|
||||||
mod lintlist;
|
mod lintlist;
|
||||||
|
@ -270,12 +270,19 @@ pub fn main() {
|
||||||
let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true);
|
let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true);
|
||||||
let have_sys_root_arg = sys_root_arg.is_some();
|
let have_sys_root_arg = sys_root_arg.is_some();
|
||||||
let sys_root = sys_root_arg
|
let sys_root = sys_root_arg
|
||||||
.map(std::string::ToString::to_string)
|
.map(PathBuf::from)
|
||||||
.or_else(|| std::env::var("SYSROOT").ok())
|
.or_else(|| std::env::var("SYSROOT").ok().map(PathBuf::from))
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
|
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
|
||||||
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
|
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
|
||||||
home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain)))
|
home.and_then(|home| {
|
||||||
|
toolchain.map(|toolchain| {
|
||||||
|
let mut path = PathBuf::from(home);
|
||||||
|
path.push("toolchains");
|
||||||
|
path.push(toolchain);
|
||||||
|
path
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
Command::new("rustc")
|
Command::new("rustc")
|
||||||
|
@ -284,9 +291,10 @@ pub fn main() {
|
||||||
.output()
|
.output()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|out| String::from_utf8(out.stdout).ok())
|
.and_then(|out| String::from_utf8(out.stdout).ok())
|
||||||
.map(|s| s.trim().to_owned())
|
.map(|s| PathBuf::from(s.trim()))
|
||||||
})
|
})
|
||||||
.or_else(|| option_env!("SYSROOT").map(String::from))
|
.or_else(|| option_env!("SYSROOT").map(PathBuf::from))
|
||||||
|
.map(|pb| pb.to_string_lossy().to_string())
|
||||||
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust");
|
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust");
|
||||||
|
|
||||||
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
|
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
|
||||||
|
|
Loading…
Reference in a new issue