]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/unnecessary_fold.rs
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / unnecessary_fold.rs
index ae667d1ac06326660af6ff5fb148c5fe5f757f49..4028d80c0a3cb9efc58f60cde0095ee7151e805a 100644 (file)
@@ -41,4 +41,12 @@ fn unnecessary_fold_should_ignore() {
     let _ = [(0..2), (0..3)].iter().fold(1, |a, b| a * b.len());
 }
 
+/// Should lint only the line containing the fold
+fn unnecessary_fold_over_multiple_lines() {
+    let _ = (0..3)
+        .map(|x| x + 1)
+        .filter(|x| x % 2 == 0)
+        .fold(false, |acc, x| acc || x > 2);
+}
+
 fn main() {}