File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -213,21 +213,18 @@ fn check_invalid_ptr_usage<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -
213213 ( & paths:: PTR_WRITE_BYTES , 0 ) ,
214214 ] ;
215215
216- let arg = INVALID_NULL_PTR_USAGE_TABLE
217- . iter ( )
218- . filter_map ( |( fn_name, arg_idx) | {
219- let args = match_function_call ( cx, expr, fn_name) ?;
220- args. iter ( ) . nth ( * arg_idx) . filter ( |arg| is_null_path ( arg) )
221- } )
222- . next ( ) ?;
216+ let arg = INVALID_NULL_PTR_USAGE_TABLE . iter ( ) . find_map ( |( fn_name, arg_idx) | {
217+ let args = match_function_call ( cx, expr, fn_name) ?;
218+ args. get ( * arg_idx) . filter ( |arg| is_null_path ( arg) )
219+ } ) ?;
223220
224221 span_lint_and_sugg (
225222 cx,
226223 INVALID_NULL_PTR_USAGE ,
227224 arg. span ,
228225 "pointer must be non-null" ,
229226 "change this to" ,
230- format ! ( "core::ptr::NonNull::dangling().as_ptr()" ) ,
227+ "core::ptr::NonNull::dangling().as_ptr()" . to_string ( ) ,
231228 Applicability :: MachineApplicable ,
232229 ) ;
233230
You can’t perform that action at this time.
0 commit comments