@@ -123,7 +123,7 @@ fn test_cow_with_ref(c: &Cow<[i32]>) {}
123
123
//~^ ptr_arg
124
124
125
125
fn test_cow ( c : Cow < [ i32 ] > ) {
126
- let _c = c;
126
+ let d = c;
127
127
}
128
128
129
129
trait Foo2 {
@@ -141,36 +141,36 @@ mod issue_5644 {
141
141
use std:: path:: PathBuf ;
142
142
143
143
fn allowed (
144
- #[ allow( clippy:: ptr_arg) ] _v : & Vec < u32 > ,
145
- #[ allow( clippy:: ptr_arg) ] _s : & String ,
146
- #[ allow( clippy:: ptr_arg) ] _p : & PathBuf ,
147
- #[ allow( clippy:: ptr_arg) ] _c : & Cow < [ i32 ] > ,
148
- #[ expect( clippy:: ptr_arg) ] _expect : & Cow < [ i32 ] > ,
144
+ #[ allow( clippy:: ptr_arg) ] v : & Vec < u32 > ,
145
+ #[ allow( clippy:: ptr_arg) ] s : & String ,
146
+ #[ allow( clippy:: ptr_arg) ] p : & PathBuf ,
147
+ #[ allow( clippy:: ptr_arg) ] c : & Cow < [ i32 ] > ,
148
+ #[ expect( clippy:: ptr_arg) ] expect : & Cow < [ i32 ] > ,
149
149
) {
150
150
}
151
151
152
- fn some_allowed ( #[ allow( clippy:: ptr_arg) ] _v : & Vec < u32 > , _s : & String ) { }
152
+ fn some_allowed ( #[ allow( clippy:: ptr_arg) ] v : & Vec < u32 > , s : & String ) { }
153
153
//~^ ptr_arg
154
154
155
155
struct S ;
156
156
impl S {
157
157
fn allowed (
158
- #[ allow( clippy:: ptr_arg) ] _v : & Vec < u32 > ,
159
- #[ allow( clippy:: ptr_arg) ] _s : & String ,
160
- #[ allow( clippy:: ptr_arg) ] _p : & PathBuf ,
161
- #[ allow( clippy:: ptr_arg) ] _c : & Cow < [ i32 ] > ,
162
- #[ expect( clippy:: ptr_arg) ] _expect : & Cow < [ i32 ] > ,
158
+ #[ allow( clippy:: ptr_arg) ] v : & Vec < u32 > ,
159
+ #[ allow( clippy:: ptr_arg) ] s : & String ,
160
+ #[ allow( clippy:: ptr_arg) ] p : & PathBuf ,
161
+ #[ allow( clippy:: ptr_arg) ] c : & Cow < [ i32 ] > ,
162
+ #[ expect( clippy:: ptr_arg) ] expect : & Cow < [ i32 ] > ,
163
163
) {
164
164
}
165
165
}
166
166
167
167
trait T {
168
168
fn allowed (
169
- #[ allow( clippy:: ptr_arg) ] _v : & Vec < u32 > ,
170
- #[ allow( clippy:: ptr_arg) ] _s : & String ,
171
- #[ allow( clippy:: ptr_arg) ] _p : & PathBuf ,
172
- #[ allow( clippy:: ptr_arg) ] _c : & Cow < [ i32 ] > ,
173
- #[ expect( clippy:: ptr_arg) ] _expect : & Cow < [ i32 ] > ,
169
+ #[ allow( clippy:: ptr_arg) ] v : & Vec < u32 > ,
170
+ #[ allow( clippy:: ptr_arg) ] s : & String ,
171
+ #[ allow( clippy:: ptr_arg) ] p : & PathBuf ,
172
+ #[ allow( clippy:: ptr_arg) ] c : & Cow < [ i32 ] > ,
173
+ #[ expect( clippy:: ptr_arg) ] expect : & Cow < [ i32 ] > ,
174
174
) {
175
175
}
176
176
}
@@ -182,22 +182,22 @@ mod issue6509 {
182
182
fn foo_vec ( vec : & Vec < u8 > ) {
183
183
//~^ ptr_arg
184
184
185
- let _ = vec. clone ( ) . pop ( ) ;
186
- let _ = vec. clone ( ) . clone ( ) ;
185
+ let a = vec. clone ( ) . pop ( ) ;
186
+ let b = vec. clone ( ) . clone ( ) ;
187
187
}
188
188
189
189
fn foo_path ( path : & PathBuf ) {
190
190
//~^ ptr_arg
191
191
192
- let _ = path. clone ( ) . pop ( ) ;
193
- let _ = path. clone ( ) . clone ( ) ;
192
+ let c = path. clone ( ) . pop ( ) ;
193
+ let d = path. clone ( ) . clone ( ) ;
194
194
}
195
195
196
- fn foo_str ( str : & PathBuf ) {
196
+ fn foo_str ( str : & String ) {
197
197
//~^ ptr_arg
198
198
199
- let _ = str. clone ( ) . pop ( ) ;
200
- let _ = str. clone ( ) . clone ( ) ;
199
+ let e = str. clone ( ) . pop ( ) ;
200
+ let f = str. clone ( ) . clone ( ) ;
201
201
}
202
202
}
203
203
@@ -340,8 +340,8 @@ mod issue_13308 {
340
340
ToOwned :: clone_into ( source, destination) ;
341
341
}
342
342
343
- fn h1 ( _ : & <String as Deref >:: Target ) { }
344
- fn h2 < T : Deref > ( _ : T , _ : & T :: Target ) { }
343
+ fn h1 ( x : & <String as Deref >:: Target ) { }
344
+ fn h2 < T : Deref > ( x : T , y : & T :: Target ) { }
345
345
346
346
// Other cases that are still ok to lint and ideally shouldn't regress
347
347
fn good ( v1 : & String , v2 : & String ) {
@@ -352,3 +352,91 @@ mod issue_13308 {
352
352
h2 ( String :: new ( ) , v2) ;
353
353
}
354
354
}
355
+
356
+ mod issue_13489_and_13728 {
357
+ // This is a no-lint from now on.
358
+ fn foo ( _x : & Vec < i32 > ) {
359
+ todo ! ( ) ;
360
+ }
361
+
362
+ // But this still gives us a lint.
363
+ fn foo_used ( x : & Vec < i32 > ) {
364
+ //~^ ptr_arg
365
+
366
+ todo ! ( ) ;
367
+ }
368
+
369
+ // This is also a no-lint from now on.
370
+ fn foo_local ( x : & Vec < i32 > ) {
371
+ let _y = x;
372
+
373
+ todo ! ( ) ;
374
+ }
375
+
376
+ // But this still gives us a lint.
377
+ fn foo_local_used ( x : & Vec < i32 > ) {
378
+ //~^ ptr_arg
379
+
380
+ let y = x;
381
+
382
+ todo ! ( ) ;
383
+ }
384
+
385
+ // This only lints once from now on.
386
+ fn foofoo ( _x : & Vec < i32 > , y : & String ) {
387
+ //~^ ptr_arg
388
+
389
+ todo ! ( ) ;
390
+ }
391
+
392
+ // And this is also a no-lint from now on.
393
+ fn foofoo_local ( _x : & Vec < i32 > , y : & String ) {
394
+ let _z = y;
395
+
396
+ todo ! ( ) ;
397
+ }
398
+ }
399
+
400
+ mod issue_13489_and_13728_mut {
401
+ // This is a no-lint from now on.
402
+ fn bar ( _x : & mut Vec < u32 > ) {
403
+ todo ! ( )
404
+ }
405
+
406
+ // But this still gives us a lint.
407
+ fn bar_used ( x : & mut Vec < u32 > ) {
408
+ //~^ ptr_arg
409
+
410
+ todo ! ( )
411
+ }
412
+
413
+ // This is also a no-lint from now on.
414
+ fn bar_local ( x : & mut Vec < u32 > ) {
415
+ let _y = x;
416
+
417
+ todo ! ( )
418
+ }
419
+
420
+ // But this still gives us a lint.
421
+ fn bar_local_used ( x : & mut Vec < u32 > ) {
422
+ //~^ ptr_arg
423
+
424
+ let y = x;
425
+
426
+ todo ! ( )
427
+ }
428
+
429
+ // This only lints once from now on.
430
+ fn barbar ( _x : & mut Vec < u32 > , y : & mut String ) {
431
+ //~^ ptr_arg
432
+
433
+ todo ! ( )
434
+ }
435
+
436
+ // And this is also a no-lint from now on.
437
+ fn barbar_local ( _x : & mut Vec < u32 > , y : & mut String ) {
438
+ let _z = y;
439
+
440
+ todo ! ( )
441
+ }
442
+ }
0 commit comments