Closed
Description
forbid
is not honored when it is followed by an allow
on the same "scope level". This compiles, but should fail:
#![forbid(unused)]
#![allow(unused)]
fn square(num: i32) -> i32 {
num * num
}
If we move the allow
down to the function level, it fails to compile as expected:
#![forbid(unused)]
#[allow(unused)]
fn square(num: i32) -> i32 {
num * num
}
The same issue also arises with CLI arguments, which all share the "scope level". That was worked around with in #70918, but once the above is fixed, that hack can likely be removed.
Original description
According to my understanding, the purpose of -F
/forbid
for lints is that they can not be allowed any more. Thus I would expect that calling rustc with -Funused -Aunused
will fail when there is unused code in the file.
However, that is not the case: with that sequence of arguments, unused code is silently accepted.
Metadata
Metadata
Assignees
Labels
Area: Compiler frontend (errors, parsing and HIR)Area: Lints (warnings about flaws in source code) such as unused_mut.Category: This is a bug.Helping to "clean up" bugs with minimal examples and bisectionsHigh priorityRelevant to the compiler team, which will review and decide on the PR/issue.Working group: DiagnosticsPerformance or correctness regression from one stable version to another.