Skip to content

Conversation

ada4a
Copy link
Contributor

@ada4a ada4a commented Oct 8, 2025

Resolves #13865

Unresolved questions:

  • Does this need more documentation?
  • It could be nice to be able to specify a lint reason
  • It could be nice to have expect-like behavior

changelog: introduce #[clippy::ignore_interior_mutability] attribute, analogous to the config option of the same name

r? @llogiq

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 8, 2025
@ada4a
Copy link
Contributor Author

ada4a commented Oct 8, 2025

Currently depends on #15763, so @rustbot blocked

@rustbot rustbot added S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Oct 8, 2025
@ada4a ada4a force-pushed the 13865-ignore_interior_mutability branch from f1810d7 to ab48eee Compare October 8, 2025 13:57
@Jarcho
Copy link
Contributor

Jarcho commented Oct 8, 2025

This is going to need a discussion. Unlike the config, the person adding the attribute is not same person who suffers the outcome. Two things of the top of my head:

  • Interior mutability is treated specially by multiple lints so we need to make sure it's clear when to use the attribute and what the actual results are.
  • Types with generics need some care. Foo<Cell<_>> should probably ignore the attribute on Foo and be detected as interior mutability anyways.

For the name I would use private_interior_mutability.

@rustbot

This comment has been minimized.

ada4a added 8 commits October 11, 2025 10:48
Their meanings, and the way they're handled in `get_attr`, are pretty
similar
- Move it and its helper function `parse_attrs` together to the end
  of the file, because it's surprising to see front-and-center a struct
  that's only really used in one place (`cognitive_complexity`).
- Avoid panic path in `LimitStack::limit`
- Replace `assert` with `debug_assert` to avoid panics in release builds
This will be required for the next commit -- kept as a separate commit
to reduce noise
@ada4a ada4a force-pushed the 13865-ignore_interior_mutability branch from ab48eee to 1087095 Compare October 11, 2025 08:56
@rustbot
Copy link
Collaborator

rustbot commented Oct 11, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@y21
Copy link
Member

y21 commented Oct 11, 2025

If we do go with the attribute, it should also be documented in book/src/attribs.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idea: Allow #[allow(clippy::mutable_key_type)] on type definitions

5 participants