We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
if let
manual_flatten
1 parent bffd402 commit 8a29f65Copy full SHA for 8a29f65
clippy_lints/src/loops/manual_flatten.rs
@@ -1,6 +1,7 @@
1
use super::utils::make_iterator_snippet;
2
use super::MANUAL_FLATTEN;
3
use clippy_utils::diagnostics::span_lint_and_then;
4
+use clippy_utils::visitors::LocalUsedVisitor;
5
use clippy_utils::{is_lang_ctor, path_to_local_id};
6
use if_chain::if_chain;
7
use rustc_errors::Applicability;
@@ -47,6 +48,9 @@ pub(super) fn check<'tcx>(
47
48
let some_ctor = is_lang_ctor(cx, qpath, OptionSome);
49
let ok_ctor = is_lang_ctor(cx, qpath, ResultOk);
50
if some_ctor || ok_ctor;
51
+ // Ensure epxr in `if let` is not used afterwards
52
+ let mut used_visitor = LocalUsedVisitor::new(cx, pat_hir_id);
53
+ if !match_arms.iter().any(|arm| used_visitor.check_arm(arm));
54
then {
55
let if_let_type = if some_ctor { "Some" } else { "Ok" };
56
// Prepare the error message
0 commit comments