diff options
| author | dswij <dharmasw@outlook.com> | 2025-02-08 04:17:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-08 04:17:43 +0000 |
| commit | 5211148dbd5493a673c0711d208497c22b12737b (patch) | |
| tree | 7a19707ebd320d42555515ef546c39b735e54086 | |
| parent | a25e1526e4b18f37c7187e7b6eff7c902403b1a0 (diff) | |
| parent | 665e78f20febeef66a05a6509154646c4eb09145 (diff) | |
| download | rust-5211148dbd5493a673c0711d208497c22b12737b.tar.gz rust-5211148dbd5493a673c0711d208497c22b12737b.zip | |
add MSRV check for `manual_flatten` (#14086)
`manual_flatten` should respect MSRV. changelog: [`manual_flatten`]: add MSRV check
| -rw-r--r-- | book/src/lint_configuration.md | 1 | ||||
| -rw-r--r-- | clippy_config/src/conf.rs | 1 | ||||
| -rw-r--r-- | clippy_lints/src/loops/manual_flatten.rs | 3 | ||||
| -rw-r--r-- | clippy_lints/src/loops/mod.rs | 2 |
4 files changed, 6 insertions, 1 deletions
diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index 190f4dd1345..6803a1db2bb 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -744,6 +744,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio * [`manual_bits`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits) * [`manual_c_str_literals`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals) * [`manual_clamp`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp) +* [`manual_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten) * [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one) * [`manual_is_ascii_check`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check) * [`manual_let_else`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs index 1dd53b04940..a356584f973 100644 --- a/clippy_config/src/conf.rs +++ b/clippy_config/src/conf.rs @@ -613,6 +613,7 @@ define_Conf! { manual_bits, manual_c_str_literals, manual_clamp, + manual_flatten, manual_hash_one, manual_is_ascii_check, manual_let_else, diff --git a/clippy_lints/src/loops/manual_flatten.rs b/clippy_lints/src/loops/manual_flatten.rs index 366c310592f..ffeb7e889c2 100644 --- a/clippy_lints/src/loops/manual_flatten.rs +++ b/clippy_lints/src/loops/manual_flatten.rs @@ -1,6 +1,7 @@ use super::MANUAL_FLATTEN; use super::utils::make_iterator_snippet; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::visitors::is_local_used; use clippy_utils::{higher, path_to_local_id, peel_blocks_with_stmt}; use rustc_errors::Applicability; @@ -18,6 +19,7 @@ pub(super) fn check<'tcx>( arg: &'tcx Expr<'_>, body: &'tcx Expr<'_>, span: Span, + msrv: &Msrv, ) { let inner_expr = peel_blocks_with_stmt(body); if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else: None, .. }) @@ -34,6 +36,7 @@ pub(super) fn check<'tcx>( && (some_ctor || ok_ctor) // Ensure expr in `if let` is not used afterwards && !is_local_used(cx, if_then, pat_hir_id) + && msrv.meets(msrvs::ITER_FLATTEN) { let if_let_type = if some_ctor { "Some" } else { "Ok" }; // Prepare the error message diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index cdc8c18c3b7..ffe7566f5fb 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -859,7 +859,7 @@ impl Loops { mut_range_bound::check(cx, arg, body); single_element_loop::check(cx, pat, arg, body, expr); same_item_push::check(cx, pat, arg, body, expr, &self.msrv); - manual_flatten::check(cx, pat, arg, body, span); + manual_flatten::check(cx, pat, arg, body, span, &self.msrv); manual_find::check(cx, pat, arg, body, span, expr); unused_enumerate_index::check(cx, pat, arg, body); } |
