@@ -101,21 +101,25 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc
101101 return ControlFlow :: Continue ( ( ) ) ;
102102 }
103103
104- // Method call on `id` in a statement ignores any return value, so it's not a read access:
104+ // Look for method call with receiver `id`. It might be a non- read access:
105105 //
106- // id.foo(...); // Not reading `id`.
106+ // id.foo(args)
107107 //
108108 // Only assuming this for "official" methods defined on the type. For methods defined in extension
109109 // traits (identified as local, based on the orphan rule), pessimistically assume that they might
110110 // have side effects, so consider them a read.
111111 if let Some ( Node :: Expr ( parent) ) = get_parent_node ( cx. tcx , expr. hir_id )
112112 && let ExprKind :: MethodCall ( _, receiver, _, _) = parent. kind
113113 && path_to_local_id ( receiver, id)
114- && let Some ( Node :: Stmt ( ..) ) = get_parent_node ( cx. tcx , parent. hir_id )
115114 && let Some ( method_def_id) = cx. typeck_results ( ) . type_dependent_def_id ( parent. hir_id )
116115 && !method_def_id. is_local ( )
117116 {
118- return ControlFlow :: Continue ( ( ) ) ;
117+ // The method call is a statement, so the return value is not used. That's not a read access:
118+ //
119+ // id.foo(args);
120+ if let Some ( Node :: Stmt ( ..) ) = get_parent_node ( cx. tcx , parent. hir_id ) {
121+ return ControlFlow :: Continue ( ( ) ) ;
122+ }
119123 }
120124
121125 // Any other access to `id` is a read access. Stop searching.
0 commit comments