]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/tests/ui/map_flatten_fixable.fixed
Auto merge of #97944 - nikic:freebsd-update, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / map_flatten_fixable.fixed
index fec3a95edd62da54cddde339c8566e0fa56656e9..928e5bd509c3fbf6c358883647b747beba2abdc1 100644 (file)
@@ -28,4 +28,41 @@ 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() {
+    std::collections::HashMap::<u32, u32>::new()
+        .get(&0)
+        .and_then(|_| {
+// we need some newlines
+// so that the span is big enough
+// we need some newlines
+// so that the span is big enough
+// for a splitted output of the diagnostic
+            Some("")
+ // whitespace beforehand is important as well
+        });
 }