Skip to content

New lint (unnecessary_safety_comment): reverse of undocumented_unsafe_blocks #7954

Closed
@ojeda

Description

@ojeda

What it does

Warns about unexpected // SAFETY: comments (i.e. the reverse of the undocumented_unsafe_blocks lint).

This lint is similar to #6880, which is requesting the reverse of missing_safety_docs.

Drawbacks

  • A project might also be using // SAFETY: comments to explain why safe code makes other unsafe code sound, e.g. within the module.

  • Potential false positives in general (depending on how it is implemented).

Example

// SAFETY: `x` is `Some`.
x.unwrap()

Could be written as:

x.unwrap()

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions