Skip to content

Commit ebff720

Browse files
committed
Add MSRV check for bool::then_some
1 parent 528308b commit ebff720

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clippy_lints/src/methods/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -2737,7 +2737,12 @@ impl Methods {
27372737
}
27382738
},
27392739
("take", []) => needless_option_take::check(cx, expr, recv),
2740-
("then", [arg]) => unnecessary_lazy_eval::check(cx, expr, recv, arg, "then_some"),
2740+
("then", [arg]) => {
2741+
if !meets_msrv(self.msrv, msrvs::BOOL_THEN_SOME) {
2742+
return;
2743+
}
2744+
unnecessary_lazy_eval::check(cx, expr, recv, arg, "then_some");
2745+
},
27412746
("to_os_string" | "to_owned" | "to_path_buf" | "to_vec", []) => {
27422747
implicit_clone::check(cx, name, expr, recv);
27432748
},

clippy_utils/src/msrvs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ macro_rules! msrv_aliases {
1212

1313
// names may refer to stabilized feature flags or library items
1414
msrv_aliases! {
15+
1,62,0 { BOOL_THEN_SOME }
1516
1,53,0 { OR_PATTERNS, MANUAL_BITS, BTREE_MAP_RETAIN, BTREE_SET_RETAIN }
1617
1,52,0 { STR_SPLIT_ONCE, REM_EUCLID_CONST }
1718
1,51,0 { BORROW_AS_PTR, UNSIGNED_ABS }

0 commit comments

Comments
 (0)