prepare test for 8734

This commit is contained in:
Marcel Hellwig 2022-05-24 14:42:08 +02:00
parent 22673bce4c
commit 04297de2ed
3 changed files with 39 additions and 1 deletions

View file

@ -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() {

View file

@ -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() {

View file

@ -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(|_| {
| __________^