@@ -142,20 +142,19 @@ fn block_has_safety_comment(cx: &LateContext<'_>, block: &hir::Block<'_>) -> boo
142
142
/// Checks if the lines immediately preceding the item contain a safety comment.
143
143
#[ allow( clippy:: collapsible_match) ]
144
144
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 ) {
146
146
return true ;
147
147
}
148
148
149
149
if item. span . ctxt ( ) == SyntaxContext :: root ( ) {
150
150
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 {
153
152
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)
155
154
} ,
156
155
Node :: Item ( parent_item) => {
157
156
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)
159
158
} else {
160
159
// Doesn't support impls in this position. Pretend a comment was found.
161
160
return true ;
@@ -164,24 +163,22 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
164
163
Node :: Stmt ( stmt) => {
165
164
if let Some ( stmt_parent) = get_parent_node ( cx. tcx , stmt. hir_id ) {
166
165
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) ,
170
167
_ => {
171
168
// Doesn't support impls in this position. Pretend a comment was found.
172
169
return true ;
173
170
} ,
174
171
}
175
172
} 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.
177
174
return true ;
178
175
}
179
176
} ,
180
177
_ => {
181
178
// Doesn't support impls in this position. Pretend a comment was found.
182
179
return true ;
183
180
} ,
184
- }
181
+ } ;
185
182
186
183
let source_map = cx. sess ( ) . source_map ( ) ;
187
184
if let Some ( comment_start) = comment_start
0 commit comments