mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
prepare test for 8734
This commit is contained in:
parent
22673bce4c
commit
04297de2ed
3 changed files with 39 additions and 1 deletions
|
@ -29,9 +29,28 @@ fn main() {
|
|||
// mapping to Result on Result
|
||||
let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
|
||||
|
||||
issue8734();
|
||||
issue8878();
|
||||
}
|
||||
|
||||
fn issue8734() {
|
||||
// let _ = [0u8, 1, 2, 3]
|
||||
// .into_iter()
|
||||
// .map(|n| match n {
|
||||
// 1 => [n
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)],
|
||||
// n => [n],
|
||||
// })
|
||||
// .flatten();
|
||||
}
|
||||
|
||||
#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again
|
||||
#[rustfmt::skip] // whitespace is important for this one
|
||||
fn issue8878() {
|
||||
|
|
|
@ -29,9 +29,28 @@ fn main() {
|
|||
// mapping to Result on Result
|
||||
let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
|
||||
|
||||
issue8734();
|
||||
issue8878();
|
||||
}
|
||||
|
||||
fn issue8734() {
|
||||
// let _ = [0u8, 1, 2, 3]
|
||||
// .into_iter()
|
||||
// .map(|n| match n {
|
||||
// 1 => [n
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)
|
||||
// .saturating_add(1)],
|
||||
// n => [n],
|
||||
// })
|
||||
// .flatten();
|
||||
}
|
||||
|
||||
#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again
|
||||
#[rustfmt::skip] // whitespace is important for this one
|
||||
fn issue8878() {
|
||||
|
|
|
@ -77,7 +77,7 @@ LL | let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
|
|||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error: called `map(..).flatten()` on `Option`
|
||||
--> $DIR/map_flatten_fixable.rs:40:10
|
||||
--> $DIR/map_flatten_fixable.rs:59:10
|
||||
|
|
||||
LL | .map(|_| {
|
||||
| __________^
|
||||
|
|
Loading…
Reference in a new issue