Skip to content

Commit 665e78f

Browse files
committed
add MSRV check for manual_flatten
1 parent 9135923 commit 665e78f

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

book/src/lint_configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
743743
* [`manual_bits`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits)
744744
* [`manual_c_str_literals`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals)
745745
* [`manual_clamp`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp)
746+
* [`manual_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten)
746747
* [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one)
747748
* [`manual_is_ascii_check`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check)
748749
* [`manual_let_else`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else)

clippy_config/src/conf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ define_Conf! {
612612
manual_bits,
613613
manual_c_str_literals,
614614
manual_clamp,
615+
manual_flatten,
615616
manual_hash_one,
616617
manual_is_ascii_check,
617618
manual_let_else,

clippy_lints/src/loops/manual_flatten.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::MANUAL_FLATTEN;
22
use super::utils::make_iterator_snippet;
33
use clippy_utils::diagnostics::span_lint_and_then;
4+
use clippy_utils::msrvs::{self, Msrv};
45
use clippy_utils::visitors::is_local_used;
56
use clippy_utils::{higher, path_to_local_id, peel_blocks_with_stmt};
67
use rustc_errors::Applicability;
@@ -18,6 +19,7 @@ pub(super) fn check<'tcx>(
1819
arg: &'tcx Expr<'_>,
1920
body: &'tcx Expr<'_>,
2021
span: Span,
22+
msrv: &Msrv,
2123
) {
2224
let inner_expr = peel_blocks_with_stmt(body);
2325
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else: None, .. })
@@ -34,6 +36,7 @@ pub(super) fn check<'tcx>(
3436
&& (some_ctor || ok_ctor)
3537
// Ensure expr in `if let` is not used afterwards
3638
&& !is_local_used(cx, if_then, pat_hir_id)
39+
&& msrv.meets(msrvs::ITER_FLATTEN)
3740
{
3841
let if_let_type = if some_ctor { "Some" } else { "Ok" };
3942
// Prepare the error message

clippy_lints/src/loops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ impl Loops {
831831
mut_range_bound::check(cx, arg, body);
832832
single_element_loop::check(cx, pat, arg, body, expr);
833833
same_item_push::check(cx, pat, arg, body, expr, &self.msrv);
834-
manual_flatten::check(cx, pat, arg, body, span);
834+
manual_flatten::check(cx, pat, arg, body, span, &self.msrv);
835835
manual_find::check(cx, pat, arg, body, span, expr);
836836
unused_enumerate_index::check(cx, pat, arg, body);
837837
}

0 commit comments

Comments
 (0)