]> git.lizzy.rs Git - rust.git/commitdiff
prepare test for 8734
authorMarcel Hellwig <github@cookiesoft.de>
Tue, 24 May 2022 12:42:08 +0000 (14:42 +0200)
committerMarcel Hellwig <github@cookiesoft.de>
Tue, 24 May 2022 12:42:08 +0000 (14:42 +0200)
tests/ui/map_flatten_fixable.fixed
tests/ui/map_flatten_fixable.rs
tests/ui/map_flatten_fixable.stderr

index 08aba35e14db8f07864a42e2f38c8215c6030bd6..928e5bd509c3fbf6c358883647b747beba2abdc1 100644 (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() {
index fbe2bf8a37d78722f1b1c2adb12a0769423ec50f..4345c6eee746120afc03cb46fc3e6f79a2d94f40 100644 (file)
@@ -29,9 +29,28 @@ fn option_id(x: i8) -> Option<i8> {
     // 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() {
index 5ee2afca1d001818fca2484a2fad65472209c0e9..828e24acaad6c71ce4de550f0f3bb2c02418d8ff 100644 (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(|_| {
    |  __________^