about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/assertions_on_constants.rs12
-rw-r--r--clippy_lints/src/attrs.rs4
-rw-r--r--clippy_lints/src/deprecated_lints.rs5
-rw-r--r--clippy_lints/src/fallible_impl_from.rs9
-rw-r--r--clippy_lints/src/implicit_return.rs9
-rw-r--r--clippy_lints/src/lib.rs7
-rw-r--r--clippy_lints/src/panic_unimplemented.rs84
-rw-r--r--clippy_lints/src/utils/mod.rs20
-rw-r--r--clippy_lints/src/utils/paths.rs8
-rw-r--r--src/lintlist/mod.rs7
-rw-r--r--tests/ui/deprecated.rs1
-rw-r--r--tests/ui/deprecated.stderr8
-rw-r--r--tests/ui/panic.rs61
-rw-r--r--tests/ui/panic.stderr28
-rw-r--r--tests/ui/panicking_macros.rs11
-rw-r--r--tests/ui/panicking_macros.stderr50
16 files changed, 129 insertions, 195 deletions
diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs
index 982d5ecf8d0..a52f0997d43 100644
--- a/clippy_lints/src/assertions_on_constants.rs
+++ b/clippy_lints/src/assertions_on_constants.rs
@@ -1,6 +1,5 @@
 use crate::consts::{constant, Constant};
-use crate::utils::paths;
-use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, snippet_opt, span_lint_and_help};
+use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, snippet_opt, span_lint_and_help};
 use if_chain::if_chain;
 use rustc_ast::ast::LitKind;
 use rustc_hir::{Expr, ExprKind, PatKind, UnOp};
@@ -130,10 +129,13 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
         if let ExprKind::Block(ref block, _) = arms[0].body.kind;
         if block.stmts.is_empty();
         if let Some(block_expr) = &block.expr;
-        if let ExprKind::Block(ref inner_block, _) = block_expr.kind;
-        if let Some(begin_panic_call) = &inner_block.expr;
+        // inner block is optional. unwarp it if it exists, or use the expression as is otherwise.
+        if let Some(begin_panic_call) = match block_expr.kind {
+            ExprKind::Block(ref inner_block, _) => &inner_block.expr,
+            _ => &block.expr,
+        };
         // function call
-        if let Some(args) = match_function_call(cx, begin_panic_call, &paths::BEGIN_PANIC);
+        if let Some(args) = match_panic_call(cx, begin_panic_call);
         if args.len() == 1;
         // bind the second argument of the `assert!` macro if it exists
         if let panic_message = snippet_opt(cx, args[0].span);
diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs
index 55904a0ec0a..57702dafa6a 100644
--- a/clippy_lints/src/attrs.rs
+++ b/clippy_lints/src/attrs.rs
@@ -1,7 +1,7 @@
 //! checks for attributes
 
 use crate::utils::{
-    first_line_of_span, is_present_in_source, match_def_path, paths, snippet_opt, span_lint, span_lint_and_help,
+    first_line_of_span, is_present_in_source, match_panic_def_id, snippet_opt, span_lint, span_lint_and_help,
     span_lint_and_sugg, span_lint_and_then, without_block_comments,
 };
 use if_chain::if_chain;
@@ -513,7 +513,7 @@ fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>
                 typeck_results
                     .qpath_res(qpath, path_expr.hir_id)
                     .opt_def_id()
-                    .map_or(true, |fun_id| !match_def_path(cx, fun_id, &paths::BEGIN_PANIC))
+                    .map_or(true, |fun_id| !match_panic_def_id(cx, fun_id))
             } else {
                 true
             }
diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs
index 461c6e31d3e..1c3285ed701 100644
--- a/clippy_lints/src/deprecated_lints.rs
+++ b/clippy_lints/src/deprecated_lints.rs
@@ -181,3 +181,8 @@ declare_deprecated_lint! {
     pub TEMPORARY_CSTRING_AS_PTR,
     "this lint has been uplifted to rustc and is now called `temporary_cstring_as_ptr`"
 }
+
+declare_deprecated_lint! {
+    pub PANIC_PARAMS,
+    "this lint has been uplifted to rustc and is now called `panic_fmt`"
+}
diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs
index fe817fe94f2..509a4a4e15f 100644
--- a/clippy_lints/src/fallible_impl_from.rs
+++ b/clippy_lints/src/fallible_impl_from.rs
@@ -1,5 +1,7 @@
-use crate::utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT};
-use crate::utils::{is_expn_of, is_type_diagnostic_item, match_def_path, method_chain_args, span_lint_and_then};
+use crate::utils::paths::FROM_TRAIT;
+use crate::utils::{
+    is_expn_of, is_type_diagnostic_item, match_def_path, match_panic_def_id, method_chain_args, span_lint_and_then,
+};
 use if_chain::if_chain;
 use rustc_hir as hir;
 use rustc_lint::{LateContext, LateLintPass};
@@ -84,8 +86,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h
                 if let ExprKind::Call(ref func_expr, _) = expr.kind;
                 if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind;
                 if let Some(path_def_id) = path.res.opt_def_id();
-                if match_def_path(self.lcx, path_def_id, &BEGIN_PANIC) ||
-                    match_def_path(self.lcx, path_def_id, &BEGIN_PANIC_FMT);
+                if match_panic_def_id(self.lcx, path_def_id);
                 if is_expn_of(expr.span, "unreachable").is_none();
                 then {
                     self.result.push(expr.span);
diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs
index 22c4fef32a3..ed7f3b9293d 100644
--- a/clippy_lints/src/implicit_return.rs
+++ b/clippy_lints/src/implicit_return.rs
@@ -1,8 +1,4 @@
-use crate::utils::{
-    fn_has_unsatisfiable_preds, match_def_path,
-    paths::{BEGIN_PANIC, BEGIN_PANIC_FMT},
-    snippet_opt, span_lint_and_then,
-};
+use crate::utils::{fn_has_unsatisfiable_preds, match_panic_def_id, snippet_opt, span_lint_and_then};
 use if_chain::if_chain;
 use rustc_errors::Applicability;
 use rustc_hir::intravisit::FnKind;
@@ -109,8 +105,7 @@ fn expr_match(cx: &LateContext<'_>, expr: &Expr<'_>) {
             if_chain! {
                 if let ExprKind::Path(qpath) = &expr.kind;
                 if let Some(path_def_id) = cx.qpath_res(qpath, expr.hir_id).opt_def_id();
-                if match_def_path(cx, path_def_id, &BEGIN_PANIC) ||
-                    match_def_path(cx, path_def_id, &BEGIN_PANIC_FMT);
+                if match_panic_def_id(cx, path_def_id);
                 then { }
                 else {
                     lint(cx, expr.span, expr.span, LINT_RETURN)
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index f0c1cb8d6e5..36016988b6b 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -496,6 +496,10 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         "clippy::temporary_cstring_as_ptr",
         "this lint has been uplifted to rustc and is now called `temporary_cstring_as_ptr`",
     );
+    store.register_removed(
+        "clippy::panic_params",
+        "this lint has been uplifted to rustc and is now called `panic_fmt`",
+    );
     // end deprecated lints, do not remove this comment, it’s used in `update_lints`
 
     // begin register lints, do not remove this comment, it’s used in `update_lints`
@@ -790,7 +794,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         &overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
         &panic_in_result_fn::PANIC_IN_RESULT_FN,
         &panic_unimplemented::PANIC,
-        &panic_unimplemented::PANIC_PARAMS,
         &panic_unimplemented::TODO,
         &panic_unimplemented::UNIMPLEMENTED,
         &panic_unimplemented::UNREACHABLE,
@@ -1505,7 +1508,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&open_options::NONSENSICAL_OPEN_OPTIONS),
         LintId::of(&option_env_unwrap::OPTION_ENV_UNWRAP),
         LintId::of(&overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
-        LintId::of(&panic_unimplemented::PANIC_PARAMS),
         LintId::of(&partialeq_ne_impl::PARTIALEQ_NE_IMPL),
         LintId::of(&precedence::PRECEDENCE),
         LintId::of(&ptr::CMP_NULL),
@@ -1674,7 +1676,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST),
         LintId::of(&non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
         LintId::of(&non_expressive_names::MANY_SINGLE_CHAR_NAMES),
-        LintId::of(&panic_unimplemented::PANIC_PARAMS),
         LintId::of(&ptr::CMP_NULL),
         LintId::of(&ptr::PTR_ARG),
         LintId::of(&ptr_eq::PTR_EQ),
diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs
index 6379dffd22e..31b03ecd101 100644
--- a/clippy_lints/src/panic_unimplemented.rs
+++ b/clippy_lints/src/panic_unimplemented.rs
@@ -1,31 +1,11 @@
-use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, paths, span_lint};
+use crate::utils::{is_expn_of, match_panic_call, span_lint};
 use if_chain::if_chain;
-use rustc_ast::ast::LitKind;
-use rustc_hir::{Expr, ExprKind};
+use rustc_hir::Expr;
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::Span;
 
 declare_clippy_lint! {
-    /// **What it does:** Checks for missing parameters in `panic!`.
-    ///
-    /// **Why is this bad?** Contrary to the `format!` family of macros, there are
-    /// two forms of `panic!`: if there are no parameters given, the first argument
-    /// is not a format string and used literally. So while `format!("{}")` will
-    /// fail to compile, `panic!("{}")` will not.
-    ///
-    /// **Known problems:** None.
-    ///
-    /// **Example:**
-    /// ```no_run
-    /// panic!("This `panic!` is probably missing a parameter there: {}");
-    /// ```
-    pub PANIC_PARAMS,
-    style,
-    "missing parameters in `panic!` calls"
-}
-
-declare_clippy_lint! {
     /// **What it does:** Checks for usage of `panic!`.
     ///
     /// **Why is this bad?** `panic!` will stop the execution of the executable
@@ -89,31 +69,30 @@ declare_clippy_lint! {
     "`unreachable!` should not be present in production code"
 }
 
-declare_lint_pass!(PanicUnimplemented => [PANIC_PARAMS, UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
+declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
 
 impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
-        if_chain! {
-            if let ExprKind::Block(ref block, _) = expr.kind;
-            if let Some(ref ex) = block.expr;
-            if let Some(params) = match_function_call(cx, ex, &paths::BEGIN_PANIC)
-                .or_else(|| match_function_call(cx, ex, &paths::BEGIN_PANIC_FMT));
-            then {
-                let span = get_outer_span(expr);
-                if is_expn_of(expr.span, "unimplemented").is_some() {
-                    span_lint(cx, UNIMPLEMENTED, span,
-                              "`unimplemented` should not be present in production code");
-                } else if is_expn_of(expr.span, "todo").is_some() {
-                    span_lint(cx, TODO, span,
-                              "`todo` should not be present in production code");
-                } else if is_expn_of(expr.span, "unreachable").is_some() {
-                    span_lint(cx, UNREACHABLE, span,
-                              "`unreachable` should not be present in production code");
-                } else if is_expn_of(expr.span, "panic").is_some() {
-                    span_lint(cx, PANIC, span,
-                              "`panic` should not be present in production code");
-                    match_panic(params, expr, cx);
-                }
+        if match_panic_call(cx, expr).is_some() {
+            let span = get_outer_span(expr);
+            if is_expn_of(expr.span, "unimplemented").is_some() {
+                span_lint(
+                    cx,
+                    UNIMPLEMENTED,
+                    span,
+                    "`unimplemented` should not be present in production code",
+                );
+            } else if is_expn_of(expr.span, "todo").is_some() {
+                span_lint(cx, TODO, span, "`todo` should not be present in production code");
+            } else if is_expn_of(expr.span, "unreachable").is_some() {
+                span_lint(
+                    cx,
+                    UNREACHABLE,
+                    span,
+                    "`unreachable` should not be present in production code",
+                );
+            } else if is_expn_of(expr.span, "panic").is_some() {
+                span_lint(cx, PANIC, span, "`panic` should not be present in production code");
             }
         }
     }
@@ -132,20 +111,3 @@ fn get_outer_span(expr: &Expr<'_>) -> Span {
         }
     }
 }
-
-fn match_panic(params: &[Expr<'_>], expr: &Expr<'_>, cx: &LateContext<'_>) {
-    if_chain! {
-        if let ExprKind::Lit(ref lit) = params[0].kind;
-        if is_direct_expn_of(expr.span, "panic").is_some();
-        if let LitKind::Str(ref string, _) = lit.node;
-        let string = string.as_str().replace("{{", "").replace("}}", "");
-        if let Some(par) = string.find('{');
-        if string[par..].contains('}');
-        if params[0].span.source_callee().is_none();
-        if params[0].span.lo() != params[0].span.hi();
-        then {
-            span_lint(cx, PANIC_PARAMS, params[0].span,
-                      "you probably are missing some parameter in your format string");
-        }
-    }
-}
diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs
index 87bfaf44383..5bd64dcb541 100644
--- a/clippy_lints/src/utils/mod.rs
+++ b/clippy_lints/src/utils/mod.rs
@@ -1233,7 +1233,7 @@ pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option<
 /// Usage:
 ///
 /// ```rust,ignore
-/// if let Some(args) = match_function_call(cx, begin_panic_call, &paths::BEGIN_PANIC);
+/// if let Some(args) = match_function_call(cx, cmp_max_call, &paths::CMP_MAX);
 /// ```
 pub fn match_function_call<'tcx>(
     cx: &LateContext<'tcx>,
@@ -1268,6 +1268,24 @@ pub fn match_def_path<'tcx>(cx: &LateContext<'tcx>, did: DefId, syms: &[&str]) -
     cx.match_def_path(did, &syms)
 }
 
+pub fn match_panic_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx [Expr<'tcx>]> {
+    match_function_call(cx, expr, &paths::BEGIN_PANIC)
+        .or_else(|| match_function_call(cx, expr, &paths::BEGIN_PANIC_FMT))
+        .or_else(|| match_function_call(cx, expr, &paths::PANIC_ANY))
+        .or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC))
+        .or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC_FMT))
+        .or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC_STR))
+}
+
+pub fn match_panic_def_id(cx: &LateContext<'_>, did: DefId) -> bool {
+    match_def_path(cx, did, &paths::BEGIN_PANIC)
+        || match_def_path(cx, did, &paths::BEGIN_PANIC_FMT)
+        || match_def_path(cx, did, &paths::PANIC_ANY)
+        || match_def_path(cx, did, &paths::PANICKING_PANIC)
+        || match_def_path(cx, did, &paths::PANICKING_PANIC_FMT)
+        || match_def_path(cx, did, &paths::PANICKING_PANIC_STR)
+}
+
 /// Returns the list of condition expressions and the list of blocks in a
 /// sequence of `if/else`.
 /// E.g., this returns `([a, b], [c, d, e])` for the expression
diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs
index 2be5ff93f86..137f5d18b66 100644
--- a/clippy_lints/src/utils/paths.rs
+++ b/clippy_lints/src/utils/paths.rs
@@ -8,8 +8,8 @@ pub const ANY_TRAIT: [&str; 3] = ["std", "any", "Any"];
 pub const ARC_PTR_EQ: [&str; 4] = ["alloc", "sync", "Arc", "ptr_eq"];
 pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"];
 pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"];
-pub const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"];
-pub const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"];
+pub(super) const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"];
+pub(super) const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"];
 pub const BINARY_HEAP: [&str; 4] = ["alloc", "collections", "binary_heap", "BinaryHeap"];
 pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"];
 pub const BOX: [&str; 3] = ["alloc", "boxed", "Box"];
@@ -78,6 +78,10 @@ pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
 pub const OS_STRING: [&str; 4] = ["std", "ffi", "os_str", "OsString"];
 pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
 pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
+pub(super) const PANICKING_PANIC: [&str; 3] = ["core", "panicking", "panic"];
+pub(super) const PANICKING_PANIC_FMT: [&str; 3] = ["core", "panicking", "panic_fmt"];
+pub(super) const PANICKING_PANIC_STR: [&str; 3] = ["core", "panicking", "panic_str"];
+pub(super) const PANIC_ANY: [&str; 3] = ["std", "panic", "panic_any"];
 pub const PARKING_LOT_MUTEX_GUARD: [&str; 2] = ["parking_lot", "MutexGuard"];
 pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 2] = ["parking_lot", "RwLockReadGuard"];
 pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWriteGuard"];
diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs
index a2edd6cd0bd..c5a31fac254 100644
--- a/src/lintlist/mod.rs
+++ b/src/lintlist/mod.rs
@@ -1839,13 +1839,6 @@ vec![
         module: "panic_in_result_fn",
     },
     Lint {
-        name: "panic_params",
-        group: "style",
-        desc: "missing parameters in `panic!` calls",
-        deprecation: None,
-        module: "panic_unimplemented",
-    },
-    Lint {
         name: "panicking_unwrap",
         group: "correctness",
         desc: "checks for calls of `unwrap[_err]()` that will always fail",
diff --git a/tests/ui/deprecated.rs b/tests/ui/deprecated.rs
index 56755596c97..4cbc5630d75 100644
--- a/tests/ui/deprecated.rs
+++ b/tests/ui/deprecated.rs
@@ -10,5 +10,6 @@
 #[warn(clippy::regex_macro)]
 #[warn(clippy::drop_bounds)]
 #[warn(clippy::temporary_cstring_as_ptr)]
+#[warn(clippy::panic_params)]
 
 fn main() {}
diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr
index 37b726fc00f..a348d01d734 100644
--- a/tests/ui/deprecated.stderr
+++ b/tests/ui/deprecated.stderr
@@ -72,11 +72,17 @@ error: lint `clippy::temporary_cstring_as_ptr` has been removed: `this lint has
 LL | #[warn(clippy::temporary_cstring_as_ptr)]
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+error: lint `clippy::panic_params` has been removed: `this lint has been uplifted to rustc and is now called `panic_fmt``
+  --> $DIR/deprecated.rs:13:8
+   |
+LL | #[warn(clippy::panic_params)]
+   |        ^^^^^^^^^^^^^^^^^^^^
+
 error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
   --> $DIR/deprecated.rs:1:8
    |
 LL | #[warn(clippy::str_to_string)]
    |        ^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 13 previous errors
+error: aborting due to 14 previous errors
 
diff --git a/tests/ui/panic.rs b/tests/ui/panic.rs
deleted file mode 100644
index 6e004aa9a92..00000000000
--- a/tests/ui/panic.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#![warn(clippy::panic_params)]
-#![allow(clippy::assertions_on_constants)]
-fn missing() {
-    if true {
-        panic!("{}");
-    } else if false {
-        panic!("{:?}");
-    } else {
-        assert!(true, "here be missing values: {}");
-    }
-
-    panic!("{{{this}}}");
-}
-
-fn ok_single() {
-    panic!("foo bar");
-}
-
-fn ok_inner() {
-    // Test for #768
-    assert!("foo bar".contains(&format!("foo {}", "bar")));
-}
-
-fn ok_multiple() {
-    panic!("{}", "This is {ok}");
-}
-
-fn ok_bracket() {
-    match 42 {
-        1337 => panic!("{so is this"),
-        666 => panic!("so is this}"),
-        _ => panic!("}so is that{"),
-    }
-}
-
-const ONE: u32 = 1;
-
-fn ok_nomsg() {
-    assert!({ 1 == ONE });
-    assert!(if 1 == ONE { ONE == 1 } else { false });
-}
-
-fn ok_escaped() {
-    panic!("{{ why should this not be ok? }}");
-    panic!(" or {{ that ?");
-    panic!(" or }} this ?");
-    panic!(" {or {{ that ?");
-    panic!(" }or }} this ?");
-    panic!("{{ test }");
-    panic!("{case }}");
-}
-
-fn main() {
-    missing();
-    ok_single();
-    ok_multiple();
-    ok_bracket();
-    ok_inner();
-    ok_nomsg();
-    ok_escaped();
-}
diff --git a/tests/ui/panic.stderr b/tests/ui/panic.stderr
deleted file mode 100644
index 1f8ff8ccf55..00000000000
--- a/tests/ui/panic.stderr
+++ /dev/null
@@ -1,28 +0,0 @@
-error: you probably are missing some parameter in your format string
-  --> $DIR/panic.rs:5:16
-   |
-LL |         panic!("{}");
-   |                ^^^^
-   |
-   = note: `-D clippy::panic-params` implied by `-D warnings`
-
-error: you probably are missing some parameter in your format string
-  --> $DIR/panic.rs:7:16
-   |
-LL |         panic!("{:?}");
-   |                ^^^^^^
-
-error: you probably are missing some parameter in your format string
-  --> $DIR/panic.rs:9:23
-   |
-LL |         assert!(true, "here be missing values: {}");
-   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: you probably are missing some parameter in your format string
-  --> $DIR/panic.rs:12:12
-   |
-LL |     panic!("{{{this}}}");
-   |            ^^^^^^^^^^^^
-
-error: aborting due to 4 previous errors
-
diff --git a/tests/ui/panicking_macros.rs b/tests/ui/panicking_macros.rs
index f91ccfaed74..77fcb8dfd02 100644
--- a/tests/ui/panicking_macros.rs
+++ b/tests/ui/panicking_macros.rs
@@ -1,6 +1,8 @@
 #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)]
 #![allow(clippy::assertions_on_constants)]
 
+extern crate core;
+
 fn panic() {
     let a = 2;
     panic!();
@@ -33,9 +35,18 @@ fn unreachable() {
     let b = a + 2;
 }
 
+fn core_versions() {
+    use core::{panic, todo, unimplemented, unreachable};
+    panic!();
+    todo!();
+    unimplemented!();
+    unreachable!();
+}
+
 fn main() {
     panic();
     todo();
     unimplemented();
     unreachable();
+    core_versions();
 }
diff --git a/tests/ui/panicking_macros.stderr b/tests/ui/panicking_macros.stderr
index 37c11d72a57..83234c0ed92 100644
--- a/tests/ui/panicking_macros.stderr
+++ b/tests/ui/panicking_macros.stderr
@@ -1,5 +1,5 @@
 error: `panic` should not be present in production code
-  --> $DIR/panicking_macros.rs:6:5
+  --> $DIR/panicking_macros.rs:8:5
    |
 LL |     panic!();
    |     ^^^^^^^^^
@@ -7,7 +7,7 @@ LL |     panic!();
    = note: `-D clippy::panic` implied by `-D warnings`
 
 error: `panic` should not be present in production code
-  --> $DIR/panicking_macros.rs:7:5
+  --> $DIR/panicking_macros.rs:9:5
    |
 LL |     panic!("message");
    |     ^^^^^^^^^^^^^^^^^^
@@ -15,7 +15,7 @@ LL |     panic!("message");
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `panic` should not be present in production code
-  --> $DIR/panicking_macros.rs:8:5
+  --> $DIR/panicking_macros.rs:10:5
    |
 LL |     panic!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL |     panic!("{} {}", "panic with", "multiple arguments");
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `todo` should not be present in production code
-  --> $DIR/panicking_macros.rs:14:5
+  --> $DIR/panicking_macros.rs:16:5
    |
 LL |     todo!();
    |     ^^^^^^^^
@@ -31,19 +31,19 @@ LL |     todo!();
    = note: `-D clippy::todo` implied by `-D warnings`
 
 error: `todo` should not be present in production code
-  --> $DIR/panicking_macros.rs:15:5
+  --> $DIR/panicking_macros.rs:17:5
    |
 LL |     todo!("message");
    |     ^^^^^^^^^^^^^^^^^
 
 error: `todo` should not be present in production code
-  --> $DIR/panicking_macros.rs:16:5
+  --> $DIR/panicking_macros.rs:18:5
    |
 LL |     todo!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `unimplemented` should not be present in production code
-  --> $DIR/panicking_macros.rs:22:5
+  --> $DIR/panicking_macros.rs:24:5
    |
 LL |     unimplemented!();
    |     ^^^^^^^^^^^^^^^^^
@@ -51,19 +51,19 @@ LL |     unimplemented!();
    = note: `-D clippy::unimplemented` implied by `-D warnings`
 
 error: `unimplemented` should not be present in production code
-  --> $DIR/panicking_macros.rs:23:5
+  --> $DIR/panicking_macros.rs:25:5
    |
 LL |     unimplemented!("message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `unimplemented` should not be present in production code
-  --> $DIR/panicking_macros.rs:24:5
+  --> $DIR/panicking_macros.rs:26:5
    |
 LL |     unimplemented!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `unreachable` should not be present in production code
-  --> $DIR/panicking_macros.rs:30:5
+  --> $DIR/panicking_macros.rs:32:5
    |
 LL |     unreachable!();
    |     ^^^^^^^^^^^^^^^
@@ -71,7 +71,7 @@ LL |     unreachable!();
    = note: `-D clippy::unreachable` implied by `-D warnings`
 
 error: `unreachable` should not be present in production code
-  --> $DIR/panicking_macros.rs:31:5
+  --> $DIR/panicking_macros.rs:33:5
    |
 LL |     unreachable!("message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -79,10 +79,34 @@ LL |     unreachable!("message");
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `unreachable` should not be present in production code
-  --> $DIR/panicking_macros.rs:32:5
+  --> $DIR/panicking_macros.rs:34:5
    |
 LL |     unreachable!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 12 previous errors
+error: `panic` should not be present in production code
+  --> $DIR/panicking_macros.rs:40:5
+   |
+LL |     panic!();
+   |     ^^^^^^^^^
+
+error: `todo` should not be present in production code
+  --> $DIR/panicking_macros.rs:41:5
+   |
+LL |     todo!();
+   |     ^^^^^^^^
+
+error: `unimplemented` should not be present in production code
+  --> $DIR/panicking_macros.rs:42:5
+   |
+LL |     unimplemented!();
+   |     ^^^^^^^^^^^^^^^^^
+
+error: `unreachable` should not be present in production code
+  --> $DIR/panicking_macros.rs:43:5
+   |
+LL |     unreachable!();
+   |     ^^^^^^^^^^^^^^^
+
+error: aborting due to 16 previous errors