diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2022-04-02 00:46:45 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2022-04-02 00:46:45 -0400 |
| commit | 17c8bee95a43cf9c39ec766cdaa8c6219f4126dd (patch) | |
| tree | fda8a04721d59685b2f3257c71c5124b5df01ed7 /clippy_lints | |
| parent | 30b333645d1fb7cc4f657ad2e162977db6ee4b8c (diff) | |
| download | rust-17c8bee95a43cf9c39ec766cdaa8c6219f4126dd.tar.gz rust-17c8bee95a43cf9c39ec766cdaa8c6219f4126dd.zip | |
Add a couple of examples to `undocumented_unsafe_blocks`
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/undocumented_unsafe_blocks.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index ac13a309e7b..c0947685fa1 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -15,6 +15,24 @@ declare_clippy_lint! { /// explaining why the unsafe operations performed inside /// the block are safe. /// + /// Note the comment must appear on the line(s) preceding the unsafe block + /// with nothing appearing in between. The following is ok: + /// ```ignore + /// foo( + /// // SAFETY: + /// // This is a valid safety comment + /// unsafe { *x } + /// ) + /// ``` + /// But neither of these are: + /// ```ignore + /// // SAFETY: + /// // This is not a valid safety comment + /// foo( + /// /* SAFETY: Neither is this */ unsafe { *x }, + /// ); + /// ``` + /// /// ### Why is this bad? /// Undocumented unsafe blocks can make it difficult to /// read and maintain code, as well as uncover unsoundness |
