]> git.lizzy.rs Git - rust.git/commitdiff
infallible <> infalliable in filename
authorwhodi <whodi@pop-os.localdomain>
Fri, 15 Apr 2022 18:33:53 +0000 (14:33 -0400)
committerManish Goregaokar <manishsmail@gmail.com>
Fri, 15 Apr 2022 21:18:09 +0000 (14:18 -0700)
clippy_lints/src/matches/infalliable_detructuring_match.rs [deleted file]
clippy_lints/src/matches/infallible_detructuring_match.rs [new file with mode: 0644]

diff --git a/clippy_lints/src/matches/infalliable_detructuring_match.rs b/clippy_lints/src/matches/infalliable_detructuring_match.rs
deleted file mode 100644 (file)
index 2472acb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-use clippy_utils::diagnostics::span_lint_and_sugg;
-use clippy_utils::source::snippet_with_applicability;
-use clippy_utils::{path_to_local_id, peel_blocks, strip_pat_refs};
-use rustc_errors::Applicability;
-use rustc_hir::{ExprKind, Local, MatchSource, PatKind, QPath};
-use rustc_lint::LateContext;
-
-use super::INFALLIBLE_DESTRUCTURING_MATCH;
-
-pub(crate) fn check(cx: &LateContext<'_>, local: &Local<'_>) -> bool {
-    if_chain! {
-        if !local.span.from_expansion();
-        if let Some(expr) = local.init;
-        if let ExprKind::Match(target, arms, MatchSource::Normal) = expr.kind;
-        if arms.len() == 1 && arms[0].guard.is_none();
-        if let PatKind::TupleStruct(
-            QPath::Resolved(None, variant_name), args, _) = arms[0].pat.kind;
-        if args.len() == 1;
-        if let PatKind::Binding(_, arg, ..) = strip_pat_refs(&args[0]).kind;
-        let body = peel_blocks(arms[0].body);
-        if path_to_local_id(body, arg);
-
-        then {
-            let mut applicability = Applicability::MachineApplicable;
-            span_lint_and_sugg(
-                cx,
-                INFALLIBLE_DESTRUCTURING_MATCH,
-                local.span,
-                "you seem to be trying to use `match` to destructure a single infallible pattern. \
-                Consider using `let`",
-                "try this",
-                format!(
-                    "let {}({}) = {};",
-                    snippet_with_applicability(cx, variant_name.span, "..", &mut applicability),
-                    snippet_with_applicability(cx, local.pat.span, "..", &mut applicability),
-                    snippet_with_applicability(cx, target.span, "..", &mut applicability),
-                ),
-                applicability,
-            );
-            return true;
-        }
-    }
-    false
-}
diff --git a/clippy_lints/src/matches/infallible_detructuring_match.rs b/clippy_lints/src/matches/infallible_detructuring_match.rs
new file mode 100644 (file)
index 0000000..2472acb
--- /dev/null
@@ -0,0 +1,44 @@
+use clippy_utils::diagnostics::span_lint_and_sugg;
+use clippy_utils::source::snippet_with_applicability;
+use clippy_utils::{path_to_local_id, peel_blocks, strip_pat_refs};
+use rustc_errors::Applicability;
+use rustc_hir::{ExprKind, Local, MatchSource, PatKind, QPath};
+use rustc_lint::LateContext;
+
+use super::INFALLIBLE_DESTRUCTURING_MATCH;
+
+pub(crate) fn check(cx: &LateContext<'_>, local: &Local<'_>) -> bool {
+    if_chain! {
+        if !local.span.from_expansion();
+        if let Some(expr) = local.init;
+        if let ExprKind::Match(target, arms, MatchSource::Normal) = expr.kind;
+        if arms.len() == 1 && arms[0].guard.is_none();
+        if let PatKind::TupleStruct(
+            QPath::Resolved(None, variant_name), args, _) = arms[0].pat.kind;
+        if args.len() == 1;
+        if let PatKind::Binding(_, arg, ..) = strip_pat_refs(&args[0]).kind;
+        let body = peel_blocks(arms[0].body);
+        if path_to_local_id(body, arg);
+
+        then {
+            let mut applicability = Applicability::MachineApplicable;
+            span_lint_and_sugg(
+                cx,
+                INFALLIBLE_DESTRUCTURING_MATCH,
+                local.span,
+                "you seem to be trying to use `match` to destructure a single infallible pattern. \
+                Consider using `let`",
+                "try this",
+                format!(
+                    "let {}({}) = {};",
+                    snippet_with_applicability(cx, variant_name.span, "..", &mut applicability),
+                    snippet_with_applicability(cx, local.pat.span, "..", &mut applicability),
+                    snippet_with_applicability(cx, target.span, "..", &mut applicability),
+                ),
+                applicability,
+            );
+            return true;
+        }
+    }
+    false
+}