about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_session/config.rs13
-rw-r--r--src/test/ui-fulldeps/lint-group-denied-lint-allowed.rs7
2 files changed, 17 insertions, 3 deletions
diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs
index b6b22e298ca..fd4e47baad5 100644
--- a/src/librustc_session/config.rs
+++ b/src/librustc_session/config.rs
@@ -986,19 +986,26 @@ pub fn get_cmd_lint_options(
     matches: &getopts::Matches,
     error_format: ErrorOutputType,
 ) -> (Vec<(String, lint::Level)>, bool, Option<lint::Level>) {
-    let mut lint_opts = vec![];
+    let mut lint_opts_with_position = vec![];
     let mut describe_lints = false;
 
     for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
-        for lint_name in matches.opt_strs(level.as_str()) {
+        for (arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
             if lint_name == "help" {
                 describe_lints = true;
             } else {
-                lint_opts.push((lint_name.replace("-", "_"), level));
+                lint_opts_with_position.push((arg_pos, lint_name.replace("-", "_"), level));
             }
         }
     }
 
+    lint_opts_with_position.sort_by_key(|x| x.0);
+    let lint_opts = lint_opts_with_position
+        .iter()
+        .cloned()
+        .map(|(_, lint_name, level)| (lint_name, level))
+        .collect();
+
     let lint_cap = matches.opt_str("cap-lints").map(|cap| {
         lint::Level::from_str(&cap)
             .unwrap_or_else(|| early_error(error_format, &format!("unknown lint level: `{}`", cap)))
diff --git a/src/test/ui-fulldeps/lint-group-denied-lint-allowed.rs b/src/test/ui-fulldeps/lint-group-denied-lint-allowed.rs
new file mode 100644
index 00000000000..7498745f206
--- /dev/null
+++ b/src/test/ui-fulldeps/lint-group-denied-lint-allowed.rs
@@ -0,0 +1,7 @@
+// aux-build:lint-group-plugin-test.rs
+// check-pass
+// compile-flags: -D unused -A unused-variables
+
+fn main() {
+    let x = 1;
+}