rust-lang / rust-lang/rust-clippy

Lint idea: `missing_panic_message`

Open
#14,843 1 comment 3 reactions 1 assignee View on GitHub

@qdot3 is already working on this.

Since Sep 3, 2026.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

Check if panic!, todo!, unimplemented!, unreachable! have a custom panic message configured (similar to missing_assert_message)

Advantage
  • Code documentation

  • Panic investigation

    Could help locating the panic by using its message on top of the bracktrace.

    For a software I develop, we use sentry to report error on our rust code (mostly panic)
    During one of the panic caused by a todo!, we where not sure from where it was coming from because the backtrace provided by sentry did not contain the line number.

    The message would have helped to know precisely which todo! the panic was coming from.

Drawbacks

No response

Example
fn panic_is_not_5(v: u32) {
  if v != 5 {
    panic!()
  }
}

Could be written as:

fn panic_is_not_5(v: u32) {
  if v != 5 {
    panic!("Called with the value {v} that is not 5")
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.