diff options
| author | Hudson Ayers <hayers@stanford.edu> | 2021-10-14 09:20:32 -0700 |
|---|---|---|
| committer | Hudson Ayers <hayers@stanford.edu> | 2021-10-21 10:41:19 -0700 |
| commit | e1d94b8fd1ca1a1de6a56a3c53bb105fefacdd9c (patch) | |
| tree | 9f048326e3bdd48a2c0612317248384e7cd6b9c4 | |
| parent | a9a1393cbff49bbba9e83aa164ef208485579f92 (diff) | |
| download | rust-e1d94b8fd1ca1a1de6a56a3c53bb105fefacdd9c.tar.gz rust-e1d94b8fd1ca1a1de6a56a3c53bb105fefacdd9c.zip | |
Configure saved panic locations based on location-detail flag
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs index d4cbba18029..b5e97ec8fe0 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs @@ -80,10 +80,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { line: u32, col: u32, ) -> MPlaceTy<'tcx, M::PointerTag> { - let file = - self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not); - let line = Scalar::from_u32(line); - let col = Scalar::from_u32(col); + let loc_details = &self.tcx.sess.opts.debugging_opts.location_detail; + let file = if loc_details.file { + self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not) + } else { + // FIXME: This creates a new allocation each time. It might be preferable to + // perform this allocation only once, and re-use the `MPlaceTy`. + // See https://github.com/rust-lang/rust/pull/89920#discussion_r730012398 + self.allocate_str("<redacted>", MemoryKind::CallerLocation, Mutability::Not) + }; + let line = if loc_details.line { Scalar::from_u32(line) } else { Scalar::from_u32(0) }; + let col = if loc_details.column { Scalar::from_u32(col) } else { Scalar::from_u32(0) }; // Allocate memory for `CallerLocation` struct. let loc_ty = self |
