Skip to content

declare_interior_mutable_const now fires for arcstr::ArcStr #12951

@kpreid

Description

@kpreid

Summary

The arcstr::ArcStr type is interior mutable for its reference count, but provides a macro which can safely construct const instances. As of 1.81.0-nightly (59e2c01 2024-06-17), presumably due to #12691, there is now a warning emitted even though the macro tries to suppress it — all relevant components of the macro expansion have #[allow(clippy::declare_interior_mutable_const)].

I imagine that this might be considered “working as intended”, with the solution being to configure ignore-interior-mutability much as is done with bytes. Still, this is a regression in out-of-the-box usability, so I figured I'd report it for consideration.

Lint Name

declare_interior_mutable_const

Reproducer

I tried this code:

// arcstr = { version = "1.2.0" }

const FOO: arcstr::ArcStr = arcstr::literal!("hello");

I saw this happen:

warning: a `const` item should not be interior mutable
 --> src/lib.rs:1:1
  |
1 | const FOO: arcstr::ArcStr = arcstr::literal!("hello");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I expected to see this happen: No warning

Version

rustc 1.81.0-nightly (59e2c01c2 2024-06-17)
binary: rustc
commit-hash: 59e2c01c2217a01546222e4d9ff4e6695ee8a1db
commit-date: 2024-06-17
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions