]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/let_unit.rs
Add tests for auto fixable let_unit suggestion
[rust.git] / tests / ui / let_unit.rs
index dc17c98f6a8a548552e76e9c4e297d59e2159c26..af5b1fb2ac7e4d526eb6eaa47025d75db8a7992d 100644 (file)
@@ -1,4 +1,7 @@
+// run-rustfix
+
 #![warn(clippy::let_unit_value)]
+#![allow(clippy::no_effect)]
 #![allow(unused_variables)]
 
 macro_rules! let_and_return {
@@ -17,6 +20,8 @@ fn main() {
 
     consume_units_with_for_loop(); // should be fine as well
 
+    multiline_sugg();
+
     let_and_return!(()) // should be fine
 }
 
@@ -42,5 +47,17 @@ fn consume_units_with_for_loop() {
     assert_eq!(count, 1);
 }
 
+fn multiline_sugg() {
+    let v: Vec<u8> = vec![2];
+
+    let _ = v
+        .into_iter()
+        .map(|i| i * 2)
+        .filter(|i| i % 2 == 0)
+        .map(|_| ())
+        .next()
+        .unwrap();
+}
+
 #[derive(Copy, Clone)]
 pub struct ContainsUnit(()); // should be fine