-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.
Description
Given the following code
#![warn(warnings, unused)]
fn main() {
let x = 13;
}
running rustc -A unused test.rs
shows a warning that x
is unused as expected (since the module scope takes precedence over the command-line arguments). However, rustc -A warnings
prints nothing.
This is caused by the following special handling:
rust/src/librustc_session/session.rs
Lines 1178 to 1189 in 01ffbcb
// FIXME: This is not general enough to make the warning lint completely override | |
// normal diagnostic warnings, since the warning lint can also be denied and changed | |
// later via the source code. | |
let warnings_allow = sopts | |
.lint_opts | |
.iter() | |
.filter(|&&(ref key, _)| *key == "warnings") | |
.map(|&(_, ref level)| *level == lint::Allow) | |
.last() | |
.unwrap_or(false); | |
let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow); | |
let can_emit_warnings = !(warnings_allow || cap_lints_allow); |
The FIXME already describes the problem, but I haven't found an open issue for this.
The special case was introduced by this commit as part of #21248. Looks like it is a hack needed to silence some otherwise unsilenceable warnings -- but I am not sure if the hack is still needed, or if there isn't a better way to do this.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.