Add test case for references bindings

This commit is contained in:
ThibsG 2021-10-01 17:08:22 +02:00
parent 90a72f506c
commit 268ef407a6
6 changed files with 46 additions and 2 deletions

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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