Lint unnecessary safety comments by Veykril · Pull Request #9851 · rust-lang/rust-clippy (original) (raw)

changelog: [unnecessary_safety_comment]: Add unnecessary safety comment lint

Addresses #7954

This does not necessarily catch all occurences, as doing so would require checking all expressions in the entire source which seems rather expensive. Instead what the lint does is it checks items, statements and the tail expression of blocks for safety comments, then checks if those comments are necessary or not, then linting for the unnecessary ones.

I kept the tests in one file to check that the lints do not clash with each other.