Skip to content

Commit 58710d2

Browse files
committed
Formatting + extra test
1 parent d70fb58 commit 58710d2

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

clippy_lints/src/undocumented_unsafe_blocks.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,9 @@ fn span_has_safety_comment(cx: &LateContext<'_>, span: Span, accept_comment_abov
728728
}
729729

730730
/// Checks if the given text has a safety comment for the immediately proceeding line.
731-
///
732-
/// If `accept_comment_above_attributes` is true, it will ignore attributes inbetween blocks of comments
731+
///
732+
/// If `accept_comment_above_attributes` is true, it will ignore attributes inbetween blocks of
733+
/// comments
733734
fn text_has_safety_comment(
734735
src: &str,
735736
line_starts: &[RelativeBytePos],

tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,5 +482,13 @@ help: consider removing the safety comment
482482
LL | // SAFETY: ...
483483
| ^^^^^^^^^^^^^^
484484

485-
error: aborting due to 55 previous errors
485+
error: unsafe block missing a safety comment
486+
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:765:9
487+
|
488+
LL | unsafe {}
489+
| ^^^^^^^^^
490+
|
491+
= help: consider adding a safety comment on the preceding line
492+
493+
error: aborting due to 56 previous errors
486494

tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,14 @@ mod issue_todo {
757757
#[doc(hidden)]
758758
mod y {}
759759
//~[default]^ unnecessary_safety_comment
760+
761+
fn foo() {
762+
#[doc(hidden)]
763+
// SAFETY: unnecessary_safety_comment should not trigger here
764+
#[allow(unsafe_code)]
765+
unsafe {}
766+
//~[disabled]^ undocumented_unsafe_blocks
767+
}
760768
}
761769

762770
fn main() {}

0 commit comments

Comments
 (0)