]> git.lizzy.rs Git - rust.git/commitdiff
fix
authortamaron <tamaron1203@gmail.com>
Thu, 12 May 2022 03:33:05 +0000 (12:33 +0900)
committertamaron <tamaron1203@gmail.com>
Thu, 12 May 2022 03:33:05 +0000 (12:33 +0900)
clippy_lints/src/undocumented_unsafe_blocks.rs

index bde7613b48eefb71a4645c6341dd863bc537b89b..5a8677f90be413bbdb9052104a7023242e674909 100644 (file)
@@ -142,20 +142,19 @@ fn block_has_safety_comment(cx: &LateContext<'_>, block: &hir::Block<'_>) -> boo
 /// Checks if the lines immediately preceding the item contain a safety comment.
 #[allow(clippy::collapsible_match)]
 fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
-    if span_from_macro_expansion_has_safety_comment(cx, item.span) || span_in_body_has_safety_comment(cx, item.span) {
+    if span_from_macro_expansion_has_safety_comment(cx, item.span) {
         return true;
     }
 
     if item.span.ctxt() == SyntaxContext::root() {
         if let Some(parent_node) = get_parent_node(cx.tcx, item.hir_id()) {
-            let comment_start;
-            match parent_node {
+            let comment_start = match parent_node {
                 Node::Crate(parent_mod) => {
-                    comment_start = comment_start_before_impl_in_mod(cx, parent_mod, parent_mod.spans.inner_span, item);
+                    comment_start_before_impl_in_mod(cx, parent_mod, parent_mod.spans.inner_span, item)
                 },
                 Node::Item(parent_item) => {
                     if let ItemKind::Mod(parent_mod) = &parent_item.kind {
-                        comment_start = comment_start_before_impl_in_mod(cx, parent_mod, parent_item.span, item);
+                        comment_start_before_impl_in_mod(cx, parent_mod, parent_item.span, item)
                     } else {
                         // Doesn't support impls in this position. Pretend a comment was found.
                         return true;
@@ -164,16 +163,14 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
                 Node::Stmt(stmt) => {
                     if let Some(stmt_parent) = get_parent_node(cx.tcx, stmt.hir_id) {
                         match stmt_parent {
-                            Node::Block(block) => {
-                                comment_start = walk_span_to_context(block.span, SyntaxContext::root()).map(Span::lo);
-                            },
+                            Node::Block(block) => walk_span_to_context(block.span, SyntaxContext::root()).map(Span::lo),
                             _ => {
                                 // Doesn't support impls in this position. Pretend a comment was found.
                                 return true;
                             },
                         }
                     } else {
-                        // Doesn't support impls in this position. Pretend a comment was found.
+                        // Problem getting the parent node. Pretend a comment was found.
                         return true;
                     }
                 },
@@ -181,7 +178,7 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
                     // Doesn't support impls in this position. Pretend a comment was found.
                     return true;
                 },
-            }
+            };
 
             let source_map = cx.sess().source_map();
             if let Some(comment_start) = comment_start