11use clippy_utils:: diagnostics:: span_lint;
2- use clippy_utils:: res:: MaybeDef ;
2+ use clippy_utils:: get_enclosing_block;
3+ use clippy_utils:: res:: { MaybeDef , MaybeResPath } ;
34use clippy_utils:: visitors:: { Visitable , for_each_expr} ;
4- use clippy_utils:: { get_enclosing_block, path_to_local_id} ;
55use core:: ops:: ControlFlow ;
66use rustc_hir:: { Body , ExprKind , HirId , LangItem , LetStmt , Node , PatKind } ;
77use rustc_lint:: { LateContext , LateLintPass } ;
@@ -81,7 +81,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
8181 // Inspect all expressions and sub-expressions in the block.
8282 for_each_expr ( cx, block, |expr| {
8383 // Ignore expressions that are not simply `id`.
84- if ! path_to_local_id ( expr, id) {
84+ if expr. res_local_id ( ) != Some ( id) {
8585 return ControlFlow :: Continue ( ( ) ) ;
8686 }
8787
@@ -93,7 +93,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
9393 // id = ...; // Not reading `id`.
9494 if let Node :: Expr ( parent) = cx. tcx . parent_hir_node ( expr. hir_id )
9595 && let ExprKind :: Assign ( lhs, ..) = parent. kind
96- && path_to_local_id ( lhs, id)
96+ && lhs. res_local_id ( ) == Some ( id)
9797 {
9898 return ControlFlow :: Continue ( ( ) ) ;
9999 }
@@ -107,7 +107,7 @@ fn has_no_read_access<'tcx, T: Visitable<'tcx>>(cx: &LateContext<'tcx>, id: HirI
107107 // have side effects, so consider them a read.
108108 if let Node :: Expr ( parent) = cx. tcx . parent_hir_node ( expr. hir_id )
109109 && let ExprKind :: MethodCall ( _, receiver, args, _) = parent. kind
110- && path_to_local_id ( receiver, id)
110+ && receiver. res_local_id ( ) == Some ( id)
111111 && let Some ( method_def_id) = cx. typeck_results ( ) . type_dependent_def_id ( parent. hir_id )
112112 && !method_def_id. is_local ( )
113113 {
0 commit comments