Skip to content

Commit 24039ca

Browse files
committed
Add msrv tests
1 parent 354172a commit 24039ca

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

tests/ui/manual_try_fold.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,19 @@ fn main() {
8282
[1, 2, 3].iter().try_fold(0i32, |sum, i| sum.checked_add(*i)).unwrap();
8383
}
8484
}
85+
86+
#[clippy::msrv = "1.26.0"]
87+
fn msrv_too_low() {
88+
[1, 2, 3]
89+
.iter()
90+
.fold(Some(0i32), |sum, i| sum?.checked_add(*i))
91+
.unwrap();
92+
}
93+
94+
#[clippy::msrv = "1.27.0"]
95+
fn msrv_juust_right() {
96+
[1, 2, 3]
97+
.iter()
98+
.fold(Some(0i32), |sum, i| sum?.checked_add(*i))
99+
.unwrap();
100+
}

tests/ui/manual_try_fold.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ error: you seem to be using `Iterator::fold` on a type that implements `Try`
1818
LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32));
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i|, ...)`
2020

21-
error: aborting due to 3 previous errors
21+
error: you seem to be using `Iterator::fold` on a type that implements `Try`
22+
--> $DIR/manual_try_fold.rs:98:10
23+
|
24+
LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i|, ...)`
26+
27+
error: aborting due to 4 previous errors
2228

0 commit comments

Comments
 (0)