diff options
3 files changed, 9 insertions, 13 deletions
diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index cfb7246f2d2..fcb3e4e6ab9 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -349,8 +349,12 @@ fn block_parents_have_safety_comment( ) -> bool { let (span, hir_id) = match cx.tcx.parent_hir_node(id) { Node::Expr(expr) => match cx.tcx.parent_hir_node(expr.hir_id) { - Node::LetStmt(hir::LetStmt { span, hir_id, .. }) => (*span, *hir_id), - + Node::LetStmt(hir::LetStmt { span, hir_id, .. }) + | Node::Expr(hir::Expr { + hir_id, + kind: hir::ExprKind::Assign(_, _, span), + .. + }) => (*span, *hir_id), node if let Some((span, hir_id)) = span_and_hid_of_item_alike_node(&node) && is_const_or_static(&node) => { diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr index 1773babbfcf..4357c455e50 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr @@ -342,13 +342,5 @@ LL | const NO_SAFETY_IN_IMPL: i32 = unsafe { 1 }; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment - --> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:673:9 - | -LL | unsafe { here_is_another_variable_with_long_name }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding a safety comment on the preceding line - -error: aborting due to 40 previous errors +error: aborting due to 39 previous errors diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs index e6002c2d22e..f3546101c96 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs @@ -668,10 +668,10 @@ fn issue_13024() { let mut just_a_simple_variable_with_a_very_long_name_that_has_seventy_eight_characters = 0; let here_is_another_variable_with_long_name = 100; - // SAFETY: good + // SAFETY: fail ONLY if `accept-comment-above-statement = false` just_a_simple_variable_with_a_very_long_name_that_has_seventy_eight_characters = unsafe { here_is_another_variable_with_long_name }; - //~^ undocumented_unsafe_blocks + //~[disabled]^ undocumented_unsafe_blocks } fn main() {} |
