-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningArea: MIR inliningC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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
// 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
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningArea: MIR inliningC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.