|
1 | 1 | use crate::utils::{
|
2 |
| - attr_by_name, attrs::is_proc_macro, is_must_use_ty, iter_input_pats, match_def_path, must_use_attr, qpath_res, |
3 |
| - return_ty, snippet, snippet_opt, span_lint, span_lint_and_help, span_lint_and_then, trait_ref_of_method, |
4 |
| - type_is_unsafe_function, |
| 2 | + attr_by_name, attrs::is_proc_macro, is_must_use_ty, is_trait_impl_item, iter_input_pats, match_def_path, |
| 3 | + must_use_attr, qpath_res, return_ty, snippet, snippet_opt, span_lint, span_lint_and_help, span_lint_and_then, |
| 4 | + trait_ref_of_method, type_is_unsafe_function, |
5 | 5 | };
|
6 |
| -use matches::matches; |
7 | 6 | use rustc::hir::map::Map;
|
8 | 7 | use rustc::lint::in_external_macro;
|
9 | 8 | use rustc::ty::{self, Ty};
|
@@ -195,20 +194,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
195 | 194 | span: Span,
|
196 | 195 | hir_id: hir::HirId,
|
197 | 196 | ) {
|
198 |
| - let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { |
199 |
| - matches!(item.kind, hir::ItemKind::Impl{ of_trait: Some(_), .. }) |
200 |
| - } else { |
201 |
| - false |
202 |
| - }; |
203 |
| - |
204 | 197 | let unsafety = match kind {
|
205 | 198 | intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _, _) => unsafety,
|
206 | 199 | intravisit::FnKind::Method(_, sig, _, _) => sig.header.unsafety,
|
207 | 200 | intravisit::FnKind::Closure(_) => return,
|
208 | 201 | };
|
209 | 202 |
|
210 | 203 | // don't warn for implementations, it's not their fault
|
211 |
| - if !is_impl { |
| 204 | + if !is_trait_impl_item(cx, hir_id) { |
212 | 205 | // don't lint extern functions decls, it's not their fault either
|
213 | 206 | match kind {
|
214 | 207 | intravisit::FnKind::Method(
|
|
0 commit comments