about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorIngvar Stepanyan <me@rreverser.com>2018-07-31 11:50:09 +0100
committerIngvar Stepanyan <me@rreverser.com>2018-07-31 11:50:09 +0100
commitc25deef110dc258ef6696daca9db228bd37c2d4b (patch)
treec766734a68c405014f7e23463b32b34fef258ef6 /src
parentca6b360c8a2c40bec3cf04bb4c9198ad30779309 (diff)
Fix check for unstable features
These features are registered only on Nightly and so matches.opt_present panics when it's called without the is_nightly guard.
Diffstat (limited to 'src')
-rw-r--r--src/bin/main.rs59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 7faa8557352..96237d533a2 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -459,38 +459,39 @@ impl GetOptsOptions {
         let rust_nightly = option_env!("CFG_RELEASE_CHANNEL")
             .map(|c| c == "nightly")
             .unwrap_or(false);
+
         if rust_nightly {
             options.unstable_features = matches.opt_present("unstable-features");
-        }
 
-        if options.unstable_features {
-            if matches.opt_present("skip-children") {
-                options.skip_children = Some(true);
-            }
-            if matches.opt_present("error-on-unformatted") {
-                options.error_on_unformatted = Some(true);
-            }
-            if let Some(ref file_lines) = matches.opt_str("file-lines") {
-                options.file_lines = file_lines.parse().map_err(err_msg)?;
-            }
-        } else {
-            let mut unstable_options = vec![];
-            if matches.opt_present("skip-children") {
-                unstable_options.push("`--skip-children`");
-            }
-            if matches.opt_present("error-on-unformatted") {
-                unstable_options.push("`--error-on-unformatted`");
-            }
-            if matches.opt_present("file-lines") {
-                unstable_options.push("`--file-lines`");
-            }
-            if !unstable_options.is_empty() {
-                let s = if unstable_options.len() == 1 { "" } else { "s" };
-                return Err(format_err!(
-                    "Unstable option{} ({}) used without `--unstable-features`",
-                    s,
-                    unstable_options.join(", "),
-                ));
+            if options.unstable_features {
+                if matches.opt_present("skip-children") {
+                    options.skip_children = Some(true);
+                }
+                if matches.opt_present("error-on-unformatted") {
+                    options.error_on_unformatted = Some(true);
+                }
+                if let Some(ref file_lines) = matches.opt_str("file-lines") {
+                    options.file_lines = file_lines.parse().map_err(err_msg)?;
+                }
+            } else {
+                let mut unstable_options = vec![];
+                if matches.opt_present("skip-children") {
+                    unstable_options.push("`--skip-children`");
+                }
+                if matches.opt_present("error-on-unformatted") {
+                    unstable_options.push("`--error-on-unformatted`");
+                }
+                if matches.opt_present("file-lines") {
+                    unstable_options.push("`--file-lines`");
+                }
+                if !unstable_options.is_empty() {
+                    let s = if unstable_options.len() == 1 { "" } else { "s" };
+                    return Err(format_err!(
+                        "Unstable option{} ({}) used without `--unstable-features`",
+                        s,
+                        unstable_options.join(", "),
+                    ));
+                }
             }
         }