$ rustc lib.rs --crate-type=lib -D unused-variables -A unused-variables
```
-You can make use of this behavior by overriding the level of one specific lint out of a group of lints. The following example denies all the lints in the `unused` group, but explicitly allows the `unused-variables` lint in that group:
+You can make use of this behavior by overriding the level of one specific lint out of a group of lints. The following example denies all the lints in the `unused` group, but explicitly allows the `unused-variables` lint in that group (forbid still trumps everything regardless of ordering):
```bash
$ rustc lib.rs --crate-type=lib -D unused -A unused-variables
let mut describe_lints = false;
for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
- for (arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
+ for (passed_arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
+ let arg_pos = if let lint::Forbid = level {
+ // forbid is always specified last, so it can't be overridden
+ usize::max_value()
+ } else {
+ passed_arg_pos
+ };
if lint_name == "help" {
describe_lints = true;
} else {
--- /dev/null
+// aux-build:lint-group-plugin-test.rs
+// compile-flags: -F unused -A unused
+
+fn main() {
+ let x = 1;
+ //~^ ERROR unused variable: `x`
+}
--- /dev/null
+error: unused variable: `x`
+ --> $DIR/lint-group-forbid-always-trumps-cli.rs:5:9
+ |
+LL | let x = 1;
+ | ^ help: if this is intentional, prefix it with an underscore: `_x`
+ |
+ = note: `-F unused-variables` implied by `-F unused`
+
+error: aborting due to previous error
+