Skip to content

Using -Z macro-backtrace breaks 'unreachable statement' with macro call #73700

@Aaron1011

Description

@Aaron1011

The following code:

fn main() {
    panic!("{}", 25);
    return ();
}

prints the following warning on nightly:

warning: unreachable statement
 --> panic_unreachable.rs:3:5
  |
2 |     panic!("{}", 25);
  |     ----------------- any code following this expression is unreachable
3 |     return ();
  |     ^^^^^^^^^^ unreachable statement
  |
  = note: `#[warn(unreachable_code)]` on by default

However, with -Z macro-backtrace, this warning is printed:

warning: unreachable statement
  --> panic_unreachable.rs:3:5
   |
3  |     return ();
   |     ^^^^^^^^^^ unreachable statement
   | 
  ::: /home/aaron/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/macros.rs:16:9
   |
16 |         $crate::rt::begin_panic_fmt(&$crate::format_args!($fmt, $($arg)+))
   |         ------------------------------------------------------------------ any code following this expression is unreachable
   |
   = note: `#[warn(unreachable_code)]` on by default

The original panic! call isn't even shown, making the "any code following this expression is unreachable" almost useless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions