Add msrv tests

This commit is contained in:
Catherine 2023-06-23 05:48:59 -05:00
parent 354172a18e
commit 24039ca2c6
2 changed files with 23 additions and 1 deletions

View File

@ -82,3 +82,19 @@ fn main() {
[1, 2, 3].iter().try_fold(0i32, |sum, i| sum.checked_add(*i)).unwrap();
}
}
#[clippy::msrv = "1.26.0"]
fn msrv_too_low() {
[1, 2, 3]
.iter()
.fold(Some(0i32), |sum, i| sum?.checked_add(*i))
.unwrap();
}
#[clippy::msrv = "1.27.0"]
fn msrv_juust_right() {
[1, 2, 3]
.iter()
.fold(Some(0i32), |sum, i| sum?.checked_add(*i))
.unwrap();
}

View File

@ -18,5 +18,11 @@ error: you seem to be using `Iterator::fold` on a type that implements `Try`
LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i|, ...)`
error: aborting due to 3 previous errors
error: you seem to be using `Iterator::fold` on a type that implements `Try`
--> $DIR/manual_try_fold.rs:98:10
|
LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i|, ...)`
error: aborting due to 4 previous errors