@@ -215,25 +215,21 @@ fn check_invalid_ptr_usage<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
215215 if let ExprKind :: Path ( ref qpath) = fun. kind;
216216 if let Some ( fun_def_id) = cx. qpath_res( qpath, fun. hir_id) . opt_def_id( ) ;
217217 let fun_def_path = cx. get_def_path( fun_def_id) . into_iter( ) . map( Symbol :: to_ident_string) . collect:: <Vec <_>>( ) ;
218- if let Some ( arg) = INVALID_NULL_PTR_USAGE_TABLE . iter( ) . find_map( |( fn_path, arg_indices) | {
219- if fn_path == & fun_def_path {
220- arg_indices. iter( ) . find_map( |arg_idx| {
221- args. get( * arg_idx) . filter( |arg| is_null_path( cx, arg) )
222- } )
223- } else {
224- None
225- }
226- } ) ;
218+ if let Some ( & ( _, arg_indices) ) = INVALID_NULL_PTR_USAGE_TABLE . iter( ) . find( |&&( fn_path, _) | fn_path == & fun_def_path) ;
227219 then {
228- span_lint_and_sugg(
229- cx,
230- INVALID_NULL_PTR_USAGE ,
231- arg. span,
232- "pointer must be non-null" ,
233- "change this to" ,
234- "core::ptr::NonNull::dangling().as_ptr()" . to_string( ) ,
235- Applicability :: MachineApplicable ,
236- ) ;
220+ for & arg_idx in arg_indices {
221+ if let Some ( arg) = args. get( arg_idx) . filter( |arg| is_null_path( cx, arg) ) {
222+ span_lint_and_sugg(
223+ cx,
224+ INVALID_NULL_PTR_USAGE ,
225+ arg. span,
226+ "pointer must be non-null" ,
227+ "change this to" ,
228+ "core::ptr::NonNull::dangling().as_ptr()" . to_string( ) ,
229+ Applicability :: MachineApplicable ,
230+ ) ;
231+ }
232+ }
237233 }
238234 }
239235}
0 commit comments