Skip to content

Commit 9e66f2d

Browse files
committed
fix
1 parent 1926217 commit 9e66f2d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

clippy_lints/src/undocumented_unsafe_blocks.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,19 @@ fn block_has_safety_comment(cx: &LateContext<'_>, block: &hir::Block<'_>) -> boo
142142
/// Checks if the lines immediately preceding the item contain a safety comment.
143143
#[allow(clippy::collapsible_match)]
144144
fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
145-
if span_from_macro_expansion_has_safety_comment(cx, item.span) || span_in_body_has_safety_comment(cx, item.span) {
145+
if span_from_macro_expansion_has_safety_comment(cx, item.span) {
146146
return true;
147147
}
148148

149149
if item.span.ctxt() == SyntaxContext::root() {
150150
if let Some(parent_node) = get_parent_node(cx.tcx, item.hir_id()) {
151-
let comment_start;
152-
match parent_node {
151+
let comment_start = match parent_node {
153152
Node::Crate(parent_mod) => {
154-
comment_start = comment_start_before_impl_in_mod(cx, parent_mod, parent_mod.spans.inner_span, item);
153+
comment_start_before_impl_in_mod(cx, parent_mod, parent_mod.spans.inner_span, item)
155154
},
156155
Node::Item(parent_item) => {
157156
if let ItemKind::Mod(parent_mod) = &parent_item.kind {
158-
comment_start = comment_start_before_impl_in_mod(cx, parent_mod, parent_item.span, item);
157+
comment_start_before_impl_in_mod(cx, parent_mod, parent_item.span, item)
159158
} else {
160159
// Doesn't support impls in this position. Pretend a comment was found.
161160
return true;
@@ -164,24 +163,22 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
164163
Node::Stmt(stmt) => {
165164
if let Some(stmt_parent) = get_parent_node(cx.tcx, stmt.hir_id) {
166165
match stmt_parent {
167-
Node::Block(block) => {
168-
comment_start = walk_span_to_context(block.span, SyntaxContext::root()).map(Span::lo);
169-
},
166+
Node::Block(block) => walk_span_to_context(block.span, SyntaxContext::root()).map(Span::lo),
170167
_ => {
171168
// Doesn't support impls in this position. Pretend a comment was found.
172169
return true;
173170
},
174171
}
175172
} else {
176-
// Doesn't support impls in this position. Pretend a comment was found.
173+
// Problem getting the parent node. Pretend a comment was found.
177174
return true;
178175
}
179176
},
180177
_ => {
181178
// Doesn't support impls in this position. Pretend a comment was found.
182179
return true;
183180
},
184-
}
181+
};
185182

186183
let source_map = cx.sess().source_map();
187184
if let Some(comment_start) = comment_start

0 commit comments

Comments
 (0)