-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"-A warnings" cannot be overwritten later by #[warn]
(but other "-A lint" can)
#75668
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
there's also the opposite problem: ; cat src/main.rs
#![deny(warnings)]
const C: usize = 1;
fn main() {
core::mem::discriminant(&1);
}
; rustc src/main.rs
; rustc src/main.rs -Wwarnings
error: constant `C` is never used
--> src/main.rs:3:7
|
3 | const C: usize = 1;
| ^
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`
error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
--> src/main.rs:6:5
|
6 | core::mem::discriminant(&1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum.
--> src/main.rs:6:29
|
6 | core::mem::discriminant(&1);
| ^^
= note: `#[deny(enum_intrinsics_non_enums)]` on by default I'd expect this to warn on |
That would be inconsistent and a bug. Consider: #[warn(warnings)]
mod outer {
// Here, warnings are warnings.
#[deny(warnings)]
mod inner {
// Here, they are errors.
}
} Command-line flags are "even more outer" than crate-level attributes, so your situation ( rustc is mostly consistent with this view I described. The issue here is about a case where it is not consistent. If you want to fundamentally change that, you should open a separate issue, and it probably has to be an RFC, since this would be a change in intended behavior. |
Given the following code
running
rustc -A unused test.rs
shows a warning thatx
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
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.
The text was updated successfully, but these errors were encountered: