1
1
use clippy_utils:: diagnostics:: span_lint;
2
2
use clippy_utils:: ty:: { is_type_diagnostic_item, is_type_lang_item} ;
3
3
use clippy_utils:: visitors:: for_each_expr_with_closures;
4
- use clippy_utils:: { get_enclosing_block, get_parent_node , path_to_local_id} ;
4
+ use clippy_utils:: { get_enclosing_block, path_to_local_id} ;
5
5
use core:: ops:: ControlFlow ;
6
6
use rustc_hir:: { Block , ExprKind , HirId , LangItem , Local , Node , PatKind } ;
7
7
use rustc_lint:: { LateContext , LateLintPass } ;
@@ -94,7 +94,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc
94
94
// `id` appearing in the left-hand side of an assignment is not a read access:
95
95
//
96
96
// id = ...; // Not reading `id`.
97
- if let Node :: Expr ( parent) = get_parent_node ( cx. tcx , expr. hir_id )
97
+ if let Node :: Expr ( parent) = cx. tcx . parent_hir_node ( expr. hir_id )
98
98
&& let ExprKind :: Assign ( lhs, ..) = parent. kind
99
99
&& path_to_local_id ( lhs, id)
100
100
{
@@ -108,7 +108,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc
108
108
// Only assuming this for "official" methods defined on the type. For methods defined in extension
109
109
// traits (identified as local, based on the orphan rule), pessimistically assume that they might
110
110
// have side effects, so consider them a read.
111
- if let Node :: Expr ( parent) = get_parent_node ( cx. tcx , expr. hir_id )
111
+ if let Node :: Expr ( parent) = cx. tcx . parent_hir_node ( expr. hir_id )
112
112
&& let ExprKind :: MethodCall ( _, receiver, _, _) = parent. kind
113
113
&& path_to_local_id ( receiver, id)
114
114
&& let Some ( method_def_id) = cx. typeck_results ( ) . type_dependent_def_id ( parent. hir_id )
@@ -117,7 +117,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc
117
117
// The method call is a statement, so the return value is not used. That's not a read access:
118
118
//
119
119
// id.foo(args);
120
- if let Node :: Stmt ( ..) = get_parent_node ( cx. tcx , parent. hir_id ) {
120
+ if let Node :: Stmt ( ..) = cx. tcx . parent_hir_node ( parent. hir_id ) {
121
121
return ControlFlow :: Continue ( ( ) ) ;
122
122
}
123
123
0 commit comments