Skip to content

Pedantic lint against unreachable!() #4959

Closed
@Luro02

Description

@Luro02

It would be nice to have a lint, that detects any use of the unreachable! macro without arguments.

This is useful for procedural macros, where only the following is shown

error: proc-macro derive panicked
 --> tests/test_union.rs:3:10
  |
3 | #[derive(ShortHand)]
  |          ^^^^^^^^^
  |
  = help: message: internal error: entered unreachable code

error: aborting due to previous error

error: could not compile `shorthand`.

To learn more, run the command again with --verbose.

This is fine, if you only have one or two uses of unreachable, but it becomes very difficult in larger codebases, because you have to check every occurrence of unreachable in the codebase.

Adding some text to the macro will be a lot more helpful!
unreachable!("ident is neither enable nor disable")

error: proc-macro derive panicked
 --> tests/test_union.rs:3:10
  |
3 | #[derive(ShortHand)]
  |          ^^^^^^^^^
  |
  = help: message: internal error: entered unreachable code: ident is neither enable nor disable

error: aborting due to previous error

error: could not compile `shorthand`.

To learn more, run the command again with --verbose.

I think panic! in a proc-macro has the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions