diff options
| author | Ralf Jung <post@ralfj.de> | 2024-12-09 08:52:23 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-12-09 15:12:33 +0100 |
| commit | 73dc95dad19e2fa513ea8ac2b76231474398c8ec (patch) | |
| tree | 76e9fef0593af5d1f0aeead0b7f3ed9d0d67da04 /compiler/rustc_const_eval/src/util | |
| parent | f33a8c6426074b7ce8d08740e9805fdca96ee150 (diff) | |
interpret: clean up deduplicating allocation functions
Diffstat (limited to 'compiler/rustc_const_eval/src/util')
| -rw-r--r-- | compiler/rustc_const_eval/src/util/caller_location.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/util/caller_location.rs b/compiler/rustc_const_eval/src/util/caller_location.rs index 9bf16d4fe16..6593547cd23 100644 --- a/compiler/rustc_const_eval/src/util/caller_location.rs +++ b/compiler/rustc_const_eval/src/util/caller_location.rs @@ -1,7 +1,7 @@ use rustc_hir::LangItem; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::layout::LayoutOf; -use rustc_middle::ty::{self, Mutability}; +use rustc_middle::ty::{self}; use rustc_middle::{bug, mir}; use rustc_span::symbol::Symbol; use tracing::trace; @@ -20,12 +20,9 @@ fn alloc_caller_location<'tcx>( // This can fail if rustc runs out of memory right here. Trying to emit an error would be // pointless, since that would require allocating more memory than these short strings. let file = if loc_details.file { - ecx.allocate_str(filename.as_str(), MemoryKind::CallerLocation, Mutability::Not).unwrap() + ecx.allocate_str_dedup(filename.as_str()).unwrap() } 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 - ecx.allocate_str("<redacted>", MemoryKind::CallerLocation, Mutability::Not).unwrap() + ecx.allocate_str_dedup("<redacted>").unwrap() }; let file = file.map_provenance(CtfeProvenance::as_immutable); let line = if loc_details.line { Scalar::from_u32(line) } else { Scalar::from_u32(0) }; |
