diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-13 20:20:57 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-23 23:54:37 +0000 |
| commit | 9ff071219bca913e45235568defadd5ab840c50a (patch) | |
| tree | b99f32ff1b7329862353a72f07e382f5fcfb1cac /compiler/rustc_middle/src/ty/context.rs | |
| parent | ace633090349fc5075b5b0d56294de985e7d1191 (diff) | |
| download | rust-9ff071219bca913e45235568defadd5ab840c50a.tar.gz rust-9ff071219bca913e45235568defadd5ab840c50a.zip | |
Give an AllocId to ConstValue::Slice.
Diffstat (limited to 'compiler/rustc_middle/src/ty/context.rs')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 51db92ecd78..aa2494a4f61 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -5,7 +5,7 @@ pub mod tls; use std::assert_matches::debug_assert_matches; -use std::borrow::Borrow; +use std::borrow::{Borrow, Cow}; use std::cmp::Ordering; use std::env::VarError; use std::ffi::OsStr; @@ -1625,7 +1625,11 @@ impl<'tcx> TyCtxt<'tcx> { /// Allocates a read-only byte or string literal for `mir::interpret` with alignment 1. /// Returns the same `AllocId` if called again with the same bytes. - pub fn allocate_bytes_dedup(self, bytes: &[u8], salt: usize) -> interpret::AllocId { + pub fn allocate_bytes_dedup<'a>( + self, + bytes: impl Into<Cow<'a, [u8]>>, + salt: usize, + ) -> interpret::AllocId { // Create an allocation that just contains these bytes. let alloc = interpret::Allocation::from_bytes_byte_aligned_immutable(bytes, ()); let alloc = self.mk_const_alloc(alloc); |
