summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/clippy_utils/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/clippy_utils/src/macros.rs')
-rw-r--r--src/tools/clippy/clippy_utils/src/macros.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/tools/clippy/clippy_utils/src/macros.rs b/src/tools/clippy/clippy_utils/src/macros.rs
index 82508bcdb..46ce4ffdc 100644
--- a/src/tools/clippy/clippy_utils/src/macros.rs
+++ b/src/tools/clippy/clippy_utils/src/macros.rs
@@ -228,16 +228,26 @@ pub enum PanicExpn<'a> {
impl<'a> PanicExpn<'a> {
pub fn parse(expr: &'a Expr<'a>) -> Option<Self> {
- let ExprKind::Call(callee, [arg, rest @ ..]) = &expr.kind else {
+ let ExprKind::Call(callee, args) = &expr.kind else {
return None;
};
let ExprKind::Path(QPath::Resolved(_, path)) = &callee.kind else {
return None;
};
- let result = match path.segments.last().unwrap().ident.as_str() {
- "panic" if arg.span.ctxt() == expr.span.ctxt() => Self::Empty,
+ let name = path.segments.last().unwrap().ident.as_str();
+
+ // This has no argument
+ if name == "panic_cold_explicit" {
+ return Some(Self::Empty);
+ };
+
+ let [arg, rest @ ..] = args else {
+ return None;
+ };
+ let result = match name {
+ "panic" if arg.span.eq_ctxt(expr.span) => Self::Empty,
"panic" | "panic_str" => Self::Str(arg),
- "panic_display" => {
+ "panic_display" | "panic_cold_display" => {
let ExprKind::AddrOf(_, _, e) = &arg.kind else {
return None;
};