]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/filter_methods.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / filter_methods.rs
diff --git a/src/tools/clippy/tests/ui/filter_methods.rs b/src/tools/clippy/tests/ui/filter_methods.rs
new file mode 100644 (file)
index 0000000..5145024
--- /dev/null
@@ -0,0 +1,25 @@
+#![warn(clippy::all, clippy::pedantic)]
+#![allow(clippy::clippy::let_underscore_drop)]
+#![allow(clippy::missing_docs_in_private_items)]
+
+fn main() {
+    let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect();
+
+    let _: Vec<_> = vec![5_i8; 6]
+        .into_iter()
+        .filter(|&x| x == 0)
+        .flat_map(|x| x.checked_mul(2))
+        .collect();
+
+    let _: Vec<_> = vec![5_i8; 6]
+        .into_iter()
+        .filter_map(|x| x.checked_mul(2))
+        .flat_map(|x| x.checked_mul(2))
+        .collect();
+
+    let _: Vec<_> = vec![5_i8; 6]
+        .into_iter()
+        .filter_map(|x| x.checked_mul(2))
+        .map(|x| x.checked_mul(2))
+        .collect();
+}