Skip to content

Commit 5211148

Browse files
authored
add MSRV check for manual_flatten (#14086)
`manual_flatten` should respect MSRV. changelog: [`manual_flatten`]: add MSRV check
2 parents a25e152 + 665e78f commit 5211148

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
@@ -744,6 +744,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
744744
* [`manual_bits`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits)
745745
* [`manual_c_str_literals`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals)
746746
* [`manual_clamp`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp)
747+
* [`manual_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten)
747748
* [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one)
748749
* [`manual_is_ascii_check`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check)
749750
* [`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
@@ -613,6 +613,7 @@ define_Conf! {
613613
manual_bits,
614614
manual_c_str_literals,
615615
manual_clamp,
616+
manual_flatten,
616617
manual_hash_one,
617618
manual_is_ascii_check,
618619
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
@@ -859,7 +859,7 @@ impl Loops {
859859
mut_range_bound::check(cx, arg, body);
860860
single_element_loop::check(cx, pat, arg, body, expr);
861861
same_item_push::check(cx, pat, arg, body, expr, &self.msrv);
862-
manual_flatten::check(cx, pat, arg, body, span);
862+
manual_flatten::check(cx, pat, arg, body, span, &self.msrv);
863863
manual_find::check(cx, pat, arg, body, span, expr);
864864
unused_enumerate_index::check(cx, pat, arg, body);
865865
}

0 commit comments

Comments
 (0)