Skip to content
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

#![warn(trivial_numeric_casts)] stays cached when commenting out or uncommenting #52387

Closed
martin-t opened this issue Jul 14, 2018 · 2 comments
Closed
Labels
A-incr-comp Area: Incremental compilation A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@martin-t
Copy link

Starting with this code:

#![warn(trivial_numeric_casts)]

fn main() {
    println!("{}", 0u8 as u8);
}

and running cargo build, it correctly warns:

warning: trivial numeric cast: `u8` as `u8`. Cast can be replaced by coercion, this might require type ascription or a temporary variable
 --> src/main.rs:4:20
  |
4 |     println!("{}", 0u8 as u8);
  |                    ^^^^^^^^^
  |
note: lint level defined here
 --> src/main.rs:1:9
  |
1 | #![warn(trivial_numeric_casts)]
  |         ^^^^^^^^^^^^^^^^^^^^^

Then I comment out the warn setting as //#![warn(trivial_numeric_casts)] and run cargo build again but it still warns:

warning: trivial numeric cast: `u8` as `u8`. Cast can be replaced by coercion, this might require type ascription or a temporary variable
 --> src/main.rs:4:20
  |
4 |     println!("{}", 0u8 as u8);
  |                    ^^^^^^^^^
  |
note: lint level defined here
 --> src/main.rs:1:9
  |
1 | //#![warn(trivial_numeric_casts)]
  |         ^^^^^^^^^^^^^^^^^^^^^

The underline is off as if the // wasn't there.

Changing the code in any way (e.g. 1u8) probably invalidates the cache because the warnings disappear.

Tested on rustc 1.27.1 (5f2b325f6 2018-07-07) and rustc 1.29.0-nightly (254f8796b 2018-07-13).

@kennytm kennytm added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. labels Jul 14, 2018
@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 29, 2019
@Enselic
Copy link
Member

Enselic commented Nov 21, 2023

Triage: I can't reproduce this any longer. Can you?

@martin-t
Copy link
Author

Tested on 1.76 nightly and it no longer happens so it probably got fixed at one point. Thanks for checking up on the issue. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants