@@ -215,20 +215,6 @@ fn option_methods() {
215
215
) ;
216
216
}
217
217
218
- /// Struct to generate false positives for things with `.iter()`.
219
- #[ derive( Copy , Clone ) ]
220
- struct HasIter ;
221
-
222
- impl HasIter {
223
- fn iter ( self ) -> IteratorFalsePositives {
224
- IteratorFalsePositives { foo : 0 }
225
- }
226
-
227
- fn iter_mut ( self ) -> IteratorFalsePositives {
228
- IteratorFalsePositives { foo : 0 }
229
- }
230
- }
231
-
232
218
/// Checks implementation of `FILTER_NEXT` lint.
233
219
#[ rustfmt:: skip]
234
220
fn filter_next ( ) {
@@ -287,100 +273,6 @@ fn search_is_some() {
287
273
let _ = foo. rposition ( ) . is_some ( ) ;
288
274
}
289
275
290
- /// Checks implementation of the `OR_FUN_CALL` lint.
291
- fn or_fun_call ( ) {
292
- struct Foo ;
293
-
294
- impl Foo {
295
- fn new ( ) -> Foo {
296
- Foo
297
- }
298
- }
299
-
300
- enum Enum {
301
- A ( i32 ) ,
302
- }
303
-
304
- fn make < T > ( ) -> T {
305
- unimplemented ! ( ) ;
306
- }
307
-
308
- let with_enum = Some ( Enum :: A ( 1 ) ) ;
309
- with_enum. unwrap_or ( Enum :: A ( 5 ) ) ;
310
-
311
- let with_const_fn = Some ( :: std:: time:: Duration :: from_secs ( 1 ) ) ;
312
- with_const_fn. unwrap_or ( :: std:: time:: Duration :: from_secs ( 5 ) ) ;
313
-
314
- let with_constructor = Some ( vec ! [ 1 ] ) ;
315
- with_constructor. unwrap_or ( make ( ) ) ;
316
-
317
- let with_new = Some ( vec ! [ 1 ] ) ;
318
- with_new. unwrap_or ( Vec :: new ( ) ) ;
319
-
320
- let with_const_args = Some ( vec ! [ 1 ] ) ;
321
- with_const_args. unwrap_or ( Vec :: with_capacity ( 12 ) ) ;
322
-
323
- let with_err: Result < _ , ( ) > = Ok ( vec ! [ 1 ] ) ;
324
- with_err. unwrap_or ( make ( ) ) ;
325
-
326
- let with_err_args: Result < _ , ( ) > = Ok ( vec ! [ 1 ] ) ;
327
- with_err_args. unwrap_or ( Vec :: with_capacity ( 12 ) ) ;
328
-
329
- let with_default_trait = Some ( 1 ) ;
330
- with_default_trait. unwrap_or ( Default :: default ( ) ) ;
331
-
332
- let with_default_type = Some ( 1 ) ;
333
- with_default_type. unwrap_or ( u64:: default ( ) ) ;
334
-
335
- let with_vec = Some ( vec ! [ 1 ] ) ;
336
- with_vec. unwrap_or ( vec ! [ ] ) ;
337
-
338
- // FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
339
-
340
- let without_default = Some ( Foo ) ;
341
- without_default. unwrap_or ( Foo :: new ( ) ) ;
342
-
343
- let mut map = HashMap :: < u64 , String > :: new ( ) ;
344
- map. entry ( 42 ) . or_insert ( String :: new ( ) ) ;
345
-
346
- let mut btree = BTreeMap :: < u64 , String > :: new ( ) ;
347
- btree. entry ( 42 ) . or_insert ( String :: new ( ) ) ;
348
-
349
- let stringy = Some ( String :: from ( "" ) ) ;
350
- let _ = stringy. unwrap_or ( "" . to_owned ( ) ) ;
351
- }
352
-
353
- /// Checks implementation of `ITER_NTH` lint.
354
- fn iter_nth ( ) {
355
- let mut some_vec = vec ! [ 0 , 1 , 2 , 3 ] ;
356
- let mut boxed_slice: Box < [ u8 ] > = Box :: new ( [ 0 , 1 , 2 , 3 ] ) ;
357
- let mut some_vec_deque: VecDeque < _ > = some_vec. iter ( ) . cloned ( ) . collect ( ) ;
358
-
359
- {
360
- // Make sure we lint `.iter()` for relevant types.
361
- let bad_vec = some_vec. iter ( ) . nth ( 3 ) ;
362
- let bad_slice = & some_vec[ ..] . iter ( ) . nth ( 3 ) ;
363
- let bad_boxed_slice = boxed_slice. iter ( ) . nth ( 3 ) ;
364
- let bad_vec_deque = some_vec_deque. iter ( ) . nth ( 3 ) ;
365
- }
366
-
367
- {
368
- // Make sure we lint `.iter_mut()` for relevant types.
369
- let bad_vec = some_vec. iter_mut ( ) . nth ( 3 ) ;
370
- }
371
- {
372
- let bad_slice = & some_vec[ ..] . iter_mut ( ) . nth ( 3 ) ;
373
- }
374
- {
375
- let bad_vec_deque = some_vec_deque. iter_mut ( ) . nth ( 3 ) ;
376
- }
377
-
378
- // Make sure we don't lint for non-relevant types.
379
- let false_positive = HasIter ;
380
- let ok = false_positive. iter ( ) . nth ( 3 ) ;
381
- let ok_mut = false_positive. iter_mut ( ) . nth ( 3 ) ;
382
- }
383
-
384
276
#[ allow( clippy:: similar_names) ]
385
277
fn main ( ) {
386
278
let opt = Some ( 0 ) ;
0 commit comments