about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-05-28 06:08:58 +0000
committerbors <bors@rust-lang.org>2021-05-28 06:08:58 +0000
commit18135ec85be45df013ecd0d1eb4a49128d043e20 (patch)
treef4c0be2032f0807d06fc6376ac9bc82e07a83f7d /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent8eef79ca9a2ff47db25905e8c21e2ffba1d353cb (diff)
parentef13f27bc7f35c4a790e2ccd94217e27869f1e14 (diff)
downloadrust-18135ec85be45df013ecd0d1eb4a49128d043e20.tar.gz
rust-18135ec85be45df013ecd0d1eb4a49128d043e20.zip
Auto merge of #85745 - veber-alex:panic_any, r=m-ou-se
Add #[track_caller] to panic_any

Report the panic location from the user code.

```rust
use std::panic;
use std::panic::panic_any;

fn main() {
    panic::set_hook(Box::new(|panic_info| {
        if let Some(location) = panic_info.location() {
            println!(
                "panic occurred in file '{}' at line {}",
                location.file(),
                location.line(),
            );
        } else {
            println!("panic occurred but can't get location information...");
        }
    }));

    panic_any(42);
}
````

Before:
`panic occurred in file '/rustc/ff2c947c00f867b9f012e28ba88cecfbe556f904/library/std/src/panic.rs' at line 59`

After:
`panic occurred in file 'src/main.rs' at line 17`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions