]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/mod.rs
Remove unnecssary lifetime from trait_ref_of_method
[rust.git] / clippy_lints / src / utils / mod.rs
index 5554b5a5727a1367f306e7c314c86ce81f841311..004a54346a6d02b042e5d077225a26492e752192 100644 (file)
@@ -315,14 +315,14 @@ pub fn implements_trait<'a, 'tcx>(
 ///     }
 /// }
 /// ```
-pub fn trait_ref_of_method(cx: &LateContext<'_, '_>, hir_id: HirId) -> Option<TraitRef> {
+pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'_, 'tcx>, hir_id: HirId) -> Option<&'tcx TraitRef> {
     // Get the implemented trait for the current function
     let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
     if_chain! {
         if parent_impl != hir::CRATE_HIR_ID;
         if let hir::Node::Item(item) = cx.tcx.hir().get_by_hir_id(parent_impl);
         if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.node;
-        then { return trait_ref.clone(); }
+        then { return trait_ref.as_ref(); }
     }
     None
 }
@@ -605,7 +605,7 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c
     })
 }
 
-pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, hir_id: HirId) -> Option<&'tcx Block> {
+pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId) -> Option<&'tcx Block> {
     let map = &cx.tcx.hir();
     let enclosing_node = map
         .get_enclosing_scope(hir_id)
@@ -978,7 +978,7 @@ pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_>, node: HirId) -> bool
     let mut prev_enclosing_node = None;
     let mut enclosing_node = node;
     while Some(enclosing_node) != prev_enclosing_node {
-        if is_automatically_derived(map.attrs_by_hir_id(enclosing_node)) {
+        if is_automatically_derived(map.attrs(enclosing_node)) {
             return true;
         }
         prev_enclosing_node = Some(enclosing_node);