Skip to content

Adjust declare_interior_mutable_const lint's category #15454

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SomeoneToIgnore
Copy link

@SomeoneToIgnore SomeoneToIgnore commented Aug 11, 2025

Per the root readme, clippy::style is a category with

code that should be written in a more idiomatic way

description.

The code this lint guards from may be much worse than badly styled:

use std::sync::LazyLock;

// `const` instead of `static` causes `dbg!` to be printed 10 times
// instead of one.
const LICENSE_FILE_NAME_REGEX: LazyLock<String> = LazyLock::new(|| {
    dbg!("I am a large regex initialized in a lazy lock!");
    format!("Hello {}", "World".to_string())
});

fn main() {
    for _ in 0..10 {
        let _ = LICENSE_FILE_NAME_REGEX.split(" ");
    }
}

In large projects, it's unfortunate but sometimes possible to see style lints suppressed with

[workspace.lints.clippy]
style = { level = "allow", priority = -1 }

effectively turning off crucial checks for the code like above.

To keep them, promote this lint to clippy::suspicious:

code that is most likely wrong or useless

category that has the same, warn default level, thus not failing on false-positives which lead to #5863


changelog: [declare_interior_mutable_const]: promote lint's category to clippy::suspicious

Per the root readme, `clippy::style` is a category with

> code that should be written in a more idiomatic way

description.

The code this lint guards from may be much worse than badly styled:

```rs
use std::sync::LazyLock;

// `const` instead of `static` causes `dbg!` to be printed 10 times
// instead of one.
const LICENSE_FILE_NAME_REGEX: LazyLock<String> = LazyLock::new(|| {
    dbg!("I am large regex initialized in a lazy lock!");
    format!("Hello {}", "World".to_string())
});

fn main() {
    for _ in 0..10 {
        let _ = LICENSE_FILE_NAME_REGEX.split(" ");
    }
}
```

In large projects, it's unfortunate but sometimes possible to see style lints suppressed with

```toml
[workspace.lints.clippy]
style = { level = "allow", priority = -1 }
```

effectively turning off crucial checks for the code like above.

To keep them, promote this lint to `clippy::suspicious`:

> code that is most likely wrong or useless

category that has the same, `warn` default level, thus not failing on false-positives which lead to rust-lang#5863
@rustbot
Copy link
Collaborator

rustbot commented Aug 11, 2025

r? @y21

rustbot has assigned @y21.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 11, 2025
Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. I opened a thread on Zulip to give others a chance to comment on this: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Moving.20declare_interior_mutable_const.20to.20suspicious

Will merge in a few days if nothing comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants