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:
|
// Only inline local functions if they would be eligible for cross-crate |
|
// inlining. This is to ensure that the final crate doesn't have MIR that |
|
// reference unexported symbols |
|
if callsite.callee.def_id().is_local() { |
|
let is_generic = callsite.callee.substs.non_erasable_generics().next().is_some(); |
|
if !is_generic && !callee_attrs.requests_inline() { |
|
return Err("not exported"); |
|
} |
|
} |
@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
In debug mode, this prints
But with optimizations, this prints:
With optimizations and
-Zinline-mir=no, this prints: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: