Skip to content

Commit 454eaec

Browse files
committed
Remove the clippy::panic-params lint.
Rustc itself now warns for all cases that triggered this lint.
1 parent a922c6b commit 454eaec

File tree

4 files changed

+4
-134
lines changed

4 files changed

+4
-134
lines changed

src/tools/clippy/clippy_lints/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
788788
&overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
789789
&panic_in_result_fn::PANIC_IN_RESULT_FN,
790790
&panic_unimplemented::PANIC,
791-
&panic_unimplemented::PANIC_PARAMS,
792791
&panic_unimplemented::TODO,
793792
&panic_unimplemented::UNIMPLEMENTED,
794793
&panic_unimplemented::UNREACHABLE,
@@ -1499,7 +1498,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
14991498
LintId::of(&open_options::NONSENSICAL_OPEN_OPTIONS),
15001499
LintId::of(&option_env_unwrap::OPTION_ENV_UNWRAP),
15011500
LintId::of(&overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
1502-
LintId::of(&panic_unimplemented::PANIC_PARAMS),
15031501
LintId::of(&partialeq_ne_impl::PARTIALEQ_NE_IMPL),
15041502
LintId::of(&precedence::PRECEDENCE),
15051503
LintId::of(&ptr::CMP_NULL),
@@ -1666,7 +1664,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16661664
LintId::of(&non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST),
16671665
LintId::of(&non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
16681666
LintId::of(&non_expressive_names::MANY_SINGLE_CHAR_NAMES),
1669-
LintId::of(&panic_unimplemented::PANIC_PARAMS),
16701667
LintId::of(&ptr::CMP_NULL),
16711668
LintId::of(&ptr::PTR_ARG),
16721669
LintId::of(&ptr_eq::PTR_EQ),

src/tools/clippy/clippy_lints/src/panic_unimplemented.rs

+4-42
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
1-
use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, span_lint};
1+
use crate::utils::{is_expn_of, match_panic_call, span_lint};
22
use if_chain::if_chain;
3-
use rustc_ast::ast::LitKind;
4-
use rustc_hir::{Expr, ExprKind};
3+
use rustc_hir::Expr;
54
use rustc_lint::{LateContext, LateLintPass};
65
use rustc_session::{declare_lint_pass, declare_tool_lint};
76
use rustc_span::Span;
87

9-
declare_clippy_lint! {
10-
/// **What it does:** Checks for missing parameters in `panic!`.
11-
///
12-
/// **Why is this bad?** Contrary to the `format!` family of macros, there are
13-
/// two forms of `panic!`: if there are no parameters given, the first argument
14-
/// is not a format string and used literally. So while `format!("{}")` will
15-
/// fail to compile, `panic!("{}")` will not.
16-
///
17-
/// **Known problems:** None.
18-
///
19-
/// **Example:**
20-
/// ```no_run
21-
/// panic!("This `panic!` is probably missing a parameter there: {}");
22-
/// ```
23-
pub PANIC_PARAMS,
24-
style,
25-
"missing parameters in `panic!` calls"
26-
}
27-
288
declare_clippy_lint! {
299
/// **What it does:** Checks for usage of `panic!`.
3010
///
@@ -89,11 +69,11 @@ declare_clippy_lint! {
8969
"`unreachable!` should not be present in production code"
9070
}
9171

92-
declare_lint_pass!(PanicUnimplemented => [PANIC_PARAMS, UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
72+
declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
9373

9474
impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
9575
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
96-
if let Some(params) = match_panic_call(cx, expr) {
76+
if let Some(_) = match_panic_call(cx, expr) {
9777
let span = get_outer_span(expr);
9878
if is_expn_of(expr.span, "unimplemented").is_some() {
9979
span_lint(
@@ -113,7 +93,6 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
11393
);
11494
} else if is_expn_of(expr.span, "panic").is_some() {
11595
span_lint(cx, PANIC, span, "`panic` should not be present in production code");
116-
match_panic(params, expr, cx);
11796
}
11897
}
11998
}
@@ -132,20 +111,3 @@ fn get_outer_span(expr: &Expr<'_>) -> Span {
132111
}
133112
}
134113
}
135-
136-
fn match_panic(params: &[Expr<'_>], expr: &Expr<'_>, cx: &LateContext<'_>) {
137-
if_chain! {
138-
if let ExprKind::Lit(ref lit) = params[0].kind;
139-
if is_direct_expn_of(expr.span, "panic").is_some();
140-
if let LitKind::Str(ref string, _) = lit.node;
141-
let string = string.as_str().replace("{{", "").replace("}}", "");
142-
if let Some(par) = string.find('{');
143-
if string[par..].contains('}');
144-
if params[0].span.source_callee().is_none();
145-
if params[0].span.lo() != params[0].span.hi();
146-
then {
147-
span_lint(cx, PANIC_PARAMS, params[0].span,
148-
"you probably are missing some parameter in your format string");
149-
}
150-
}
151-
}

src/tools/clippy/tests/ui/panic.rs

-61
This file was deleted.

src/tools/clippy/tests/ui/panic.stderr

-28
This file was deleted.

0 commit comments

Comments
 (0)