Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 138 additions & 85 deletions clippy_lints/src/undocumented_unsafe_blocks.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/ui-cargo/undocumented_unsafe_blocks/fail/Cargo.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ error: module has unnecessary safety comment
| ^^^^^^^^
|
help: consider removing the safety comment
--> src/main.rs:1:1
--> src/main.rs:1:4
|
1 | // SAFETY: ...
| ^^^^^^^^^^^^^^
| ^^^^^^^
= note: requested on the command line with `-D clippy::unnecessary-safety-comment`

error: module has unnecessary safety comment
Expand All @@ -18,9 +18,9 @@ error: module has unnecessary safety comment
| ^^^^^^^^
|
help: consider removing the safety comment
--> src/main.rs:4:1
--> src/main.rs:4:4
|
4 | // SAFETY: ...
| ^^^^^^^^^^^^^^
| ^^^^^^^

error: could not compile `undocumented_unsafe_blocks` (bin "undocumented_unsafe_blocks") due to 2 previous errors
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ LL | const BIG_NUMBER: i32 = 1000000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:507:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:507:8
|
LL | // SAFETY:
| ^^^^^^^^^^
| ^^^^^^^
= note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]`

Expand Down Expand Up @@ -289,10 +289,10 @@ LL | | };
| |______^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:542:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:542:8
|
LL | // SAFETY: this is more than one level away, so it should warn
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:545:12
Expand Down Expand Up @@ -342,17 +342,137 @@ LL | const NO_SAFETY_IN_IMPL: i32 = unsafe { 1 };
|
= help: consider adding a safety comment on the preceding line

error: constant has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:701:5
|
LL | const UNIX_EPOCH_JULIAN_DAY: i32 =
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:699:8
|
LL | // SAFETY: fail ONLY if `accept-comment-above-attribute = false`
| ^^^^^^^

error: statement has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:719:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:721:5
|
LL | _ = bar();
| ^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:718:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:720:8
|
LL | // SAFETY: unnecessary_safety_comment triggers here
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: module has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:741:5
|
LL | mod x {}
| ^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:740:8
|
LL | // SAFETY: ...
| ^^^^^^^

error: module has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:746:5
|
LL | mod y {}
| ^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:744:8
|
LL | // SAFETY: ...
| ^^^^^^^

error: module has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:751:5
|
LL | mod z {}
| ^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:750:8
|
LL | // SAFETY: ...
| ^^^^^^^

error: module has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:759:5
|
LL | mod y {}
| ^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:757:8
|
LL | // SAFETY: ...
| ^^^^^^^

error: statement has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:774:9
|
LL | let x = 34;
| ^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:772:12
|
LL | // SAFETY: ...
| ^^^^^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:781:5
|
LL | unsafe fn unsafe_comment() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the `SAFETY` comment for a `# Safety` doc comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:780:8
|
LL | // SAFETY: Bla
| ^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:787:5
|
LL | unsafe fn unsafe_block_comment() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the `SAFETY` comment for a `# Safety` doc comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:785:8
|
LL | SAFETY: Bla
| ^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:791:5
|
LL | fn safe_comment() {}
| ^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:790:8
|
LL | // SAFETY: Bla
| ^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:795:5
|
LL | fn safe_doc_comment() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:794:9
|
LL | /// SAFETY: Bla
| ^^^^^^^

error: aborting due to 40 previous errors
error: aborting due to 50 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ LL | const BIG_NUMBER: i32 = 1000000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:507:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:507:8
|
LL | // SAFETY:
| ^^^^^^^^^^
| ^^^^^^^
= note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]`

Expand Down Expand Up @@ -297,10 +297,10 @@ LL | | };
| |______^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:542:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:542:8
|
LL | // SAFETY: this is more than one level away, so it should warn
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:545:12
Expand Down Expand Up @@ -439,24 +439,104 @@ LL | unsafe { Date::__from_ordinal_date_unchecked(1970, 1) }.into_julian
= help: consider adding a safety comment on the preceding line

error: statement has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:719:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:721:5
|
LL | _ = bar();
| ^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:718:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:720:8
|
LL | // SAFETY: unnecessary_safety_comment triggers here
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:733:12
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:735:12
|
LL | return unsafe { h() };
| ^^^^^^^^^^^^^^
|
= help: consider adding a safety comment on the preceding line

error: aborting due to 53 previous errors
error: module has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:741:5
|
LL | mod x {}
| ^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:740:8
|
LL | // SAFETY: ...
| ^^^^^^^

error: module has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:751:5
|
LL | mod z {}
| ^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:750:8
|
LL | // SAFETY: ...
| ^^^^^^^

error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:766:9
|
LL | unsafe {}
| ^^^^^^^^^
|
= help: consider adding a safety comment on the preceding line

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:781:5
|
LL | unsafe fn unsafe_comment() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the `SAFETY` comment for a `# Safety` doc comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:780:8
|
LL | // SAFETY: Bla
| ^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:787:5
|
LL | unsafe fn unsafe_block_comment() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider changing the `SAFETY` comment for a `# Safety` doc comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:785:8
|
LL | SAFETY: Bla
| ^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:791:5
|
LL | fn safe_comment() {}
| ^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:790:8
|
LL | // SAFETY: Bla
| ^^^^^^^

error: function has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:795:5
|
LL | fn safe_doc_comment() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:794:9
|
LL | /// SAFETY: Bla
| ^^^^^^^

error: aborting due to 60 previous errors

Loading