Enable accurate caller location reporting during panic in {Option, Result}::{unwrap, expect}
with the following changes:
#[track_caller]
function attribute, which guarantees a function has access to the caller information.caller_location()
(safe wrapper: Location::caller()
) to retrieve the caller's source location.#![feature(track_caller)]
use std::panic::Location;
#[track_caller]
fn unwrap(self) -> T {
panic!("{}: oh no", Location::caller());
}
let n: Option<u32> = None;
let m = n.unwrap();