From df2d3c82df7ed70de7aa0d8db642b4f454228c4d Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Fri, 27 Mar 2020 12:47:57 -0700 Subject: [PATCH] check for unstable options --- src/main.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 66c1aa4d97c..4749300c3e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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()