Skip to content
Prev Previous commit
Next Next commit
check for unstable options
  • Loading branch information
yaahc committed Mar 27, 2020
commit df2d3c82df7ed70de7aa0d8db642b4f454228c4d
30 changes: 24 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,36 @@ where
{
let mut args = vec!["check".to_owned()];

let mut fix = false;
let mut unstable_options = false;

for arg in old_args.by_ref() {
if arg == "--fix" {
args[0] = "fix".to_owned();
continue;
match arg {
"--fix" => {
fix = true;
continue;
},
"--" => break,
// Cover -Zunstable-options and -Z unstable-options
s if s.ends_with("unstable-options") => unstable_options = true,
_ => {},
}

if arg == "--" {
break;
}
args.push(arg);
}

if fix && !unstable_options {
panic!("Usage of `--fix` requires `-Z unstable-options`");
} else {
args[0] = "fix".to_owned();
}

let env_name = if unstable_options {
"RUSTC_WORKSPACE_WRAPPER"
} else {
"RUSTC_WRAPPER"
};

let clippy_args: String = old_args.map(|arg| format!("{}__CLIPPY_HACKERY__", arg)).collect();

let mut path = std::env::current_exe()
Expand Down