mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
Add test case for references bindings
This commit is contained in:
parent
90a72f506c
commit
268ef407a6
6 changed files with 46 additions and 2 deletions
|
@ -174,4 +174,9 @@ mod issue7392 {
|
|||
let vfoo = vec![Foo { bar: 1 }];
|
||||
let _ = !vfoo.iter().any(|v| v.by_ref(&v.bar));
|
||||
}
|
||||
|
||||
fn ref_bindings() {
|
||||
let _ = ![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y);
|
||||
let _ = ![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,4 +180,9 @@ mod issue7392 {
|
|||
let vfoo = vec![Foo { bar: 1 }];
|
||||
let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none();
|
||||
}
|
||||
|
||||
fn ref_bindings() {
|
||||
let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none();
|
||||
let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,5 +227,17 @@ error: called `is_none()` after searching an `Iterator` with `find`
|
|||
LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.by_ref(&v.bar))`
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
error: called `is_none()` after searching an `Iterator` with `find`
|
||||
--> $DIR/search_is_some_fixable_none.rs:185:17
|
||||
|
|
||||
LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)`
|
||||
|
||||
error: called `is_none()` after searching an `Iterator` with `find`
|
||||
--> $DIR/search_is_some_fixable_none.rs:186:17
|
||||
|
|
||||
LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)`
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
|
|
|
@ -176,4 +176,9 @@ mod issue7392 {
|
|||
let vfoo = vec![Foo { bar: 1 }];
|
||||
let _ = vfoo.iter().any(|v| v.by_ref(&v.bar));
|
||||
}
|
||||
|
||||
fn ref_bindings() {
|
||||
let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y);
|
||||
let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,4 +179,9 @@ mod issue7392 {
|
|||
let vfoo = vec![Foo { bar: 1 }];
|
||||
let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some();
|
||||
}
|
||||
|
||||
fn ref_bindings() {
|
||||
let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some();
|
||||
let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,5 +210,17 @@ error: called `is_some()` after searching an `Iterator` with `find`
|
|||
LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.by_ref(&v.bar))`
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
error: called `is_some()` after searching an `Iterator` with `find`
|
||||
--> $DIR/search_is_some_fixable_some.rs:184:55
|
||||
|
|
||||
LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|(&x, y)| x == *y)`
|
||||
|
||||
error: called `is_some()` after searching an `Iterator` with `find`
|
||||
--> $DIR/search_is_some_fixable_some.rs:185:55
|
||||
|
|
||||
LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|(&x, y)| x == *y)`
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue