]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/map_err_ignore.rs
Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup
[rust.git] / clippy_lints / src / map_err_ignore.rs
index 5298e16a04d9b7d3578edc82c111fb3984cfbf9b..a6a63961be572608f29f4605131388d5af6f8420 100644 (file)
@@ -1,5 +1,4 @@
-use crate::utils::span_lint_and_help;
-
+use clippy_utils::diagnostics::span_lint_and_help;
 use rustc_hir::{CaptureBy, Expr, ExprKind, PatKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -7,7 +6,7 @@
 declare_clippy_lint! {
     /// **What it does:** Checks for instances of `map_err(|_| Some::Enum)`
     ///
-    /// **Why is this bad?** This map_err throws away the original error rather than allowing the enum to contain and report the cause of the error
+    /// **Why is this bad?** This `map_err` throws away the original error rather than allowing the enum to contain and report the cause of the error
     ///
     /// **Known problems:** None.
     ///
@@ -99,7 +98,7 @@
     /// }
     /// ```
     pub MAP_ERR_IGNORE,
-    pedantic,
+    restriction,
     "`map_err` should not ignore the original error"
 }
 
@@ -133,9 +132,9 @@ fn check_expr(&mut self, cx: &LateContext<'_>, e: &Expr<'_>) {
                                     cx,
                                     MAP_ERR_IGNORE,
                                     body_span,
-                                    "`map_err(|_|...` ignores the original error",
+                                    "`map_err(|_|...` wildcard pattern discards the original error",
                                     None,
-                                    "Consider wrapping the error in an enum variant",
+                                    "consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`)",
                                 );
                             }
                         }