Description
use core::panic::Location;
#[inline]
fn nested() -> &'static Location<'static> {
Location::caller()
}
fn main() {
println!("{:?}", nested());
}
In debug mode, this prints
Location { file: "src/main.rs", line: 5, col: 5 }
But with optimizations, this prints:
Location { file: "src/main.rs", line: 9, col: 22 }
With optimizations and -Zinline-mir=no
, this prints:
Location { file: "src/main.rs", line: 5, col: 5 }
This check in the MIR inliner is hiding this problem from the track-caller UI tests:
rust/compiler/rustc_mir_transform/src/inline.rs
Lines 336 to 344 in 32da230
@rustbot label +A-mir-opt +A-mir-opt-inlining
rustc --version --verbose
:
rustc 1.68.0-nightly (dfe3fe710 2022-12-09)
binary: rustc
commit-hash: dfe3fe710181738a2cb3060c23ec5efb3c68ca09
commit-date: 2022-12-09
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6