Skip to content

Catch transmuting Option<&T> to Option<&mut T> #372

@fhartwig

Description

@fhartwig

Rustc already has a lint (mutable_transmutes) that catches transmutes from &T to &mut T, which can cause undefined behaviour. However, it doesn't catch minor variations of this problem, like Option<&T> -> Option<&mut T>, which are presumably just as dangerous. I've seen this particular example in real code.
It would be nice to have a lint that catches this case (and ideally, other instances of the same problem, although this could get quite complex in the fully general case).

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions