Skip to content

Commit e1d94b8

Browse files
committed
Configure saved panic locations based on location-detail flag
1 parent a9a1393 commit e1d94b8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
8080
line: u32,
8181
col: u32,
8282
) -> MPlaceTy<'tcx, M::PointerTag> {
83-
let file =
84-
self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not);
85-
let line = Scalar::from_u32(line);
86-
let col = Scalar::from_u32(col);
83+
let loc_details = &self.tcx.sess.opts.debugging_opts.location_detail;
84+
let file = if loc_details.file {
85+
self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not)
86+
} else {
87+
// FIXME: This creates a new allocation each time. It might be preferable to
88+
// perform this allocation only once, and re-use the `MPlaceTy`.
89+
// See https://github.com/rust-lang/rust/pull/89920#discussion_r730012398
90+
self.allocate_str("<redacted>", MemoryKind::CallerLocation, Mutability::Not)
91+
};
92+
let line = if loc_details.line { Scalar::from_u32(line) } else { Scalar::from_u32(0) };
93+
let col = if loc_details.column { Scalar::from_u32(col) } else { Scalar::from_u32(0) };
8794

8895
// Allocate memory for `CallerLocation` struct.
8996
let loc_ty = self

0 commit comments

Comments
 (0)