diff options
| author | bors <bors@rust-lang.org> | 2025-07-24 03:35:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-24 03:35:47 +0000 |
| commit | 3c30dbbe31bfbf6029f4534170165ba573ff0fd1 (patch) | |
| tree | 4a36a0eeea740125b3e6f4e740a904294e748a98 /compiler/rustc_public/src/alloc.rs | |
| parent | efd420c770bb179537c01063e98cb6990c439654 (diff) | |
| parent | 967ba2f93d4874f920cb8732724a045b18f525c8 (diff) | |
| download | rust-3c30dbbe31bfbf6029f4534170165ba573ff0fd1.tar.gz rust-3c30dbbe31bfbf6029f4534170165ba573ff0fd1.zip | |
Auto merge of #116707 - cjgillot:slice-id, r=oli-obk,RalfJung
Create an `AllocId` for `ConstValue::Slice`. This PR modifies `ConstValue::Slice` to use an `AllocId` instead of directly manipulating the allocation. This was originally proposed by https://github.com/rust-lang/rust/pull/115764 but was a perf regression. Almost 2 years later, enough code has changed to make this a perf improvement: https://github.com/rust-lang/rust/pull/116707#issuecomment-3067158777
Diffstat (limited to 'compiler/rustc_public/src/alloc.rs')
| -rw-r--r-- | compiler/rustc_public/src/alloc.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index 75ad31022ff..0c35b3b25df 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -33,7 +33,7 @@ fn new_empty_allocation(align: Align) -> Allocation { #[allow(rustc::usage_of_qualified_ty)] pub(crate) fn new_allocation<'tcx>( ty: rustc_middle::ty::Ty<'tcx>, - const_value: ConstValue<'tcx>, + const_value: ConstValue, tables: &mut Tables<'tcx, BridgeTys>, cx: &CompilerCtxt<'tcx, BridgeTys>, ) -> Allocation { @@ -44,7 +44,7 @@ pub(crate) fn new_allocation<'tcx>( #[allow(rustc::usage_of_qualified_ty)] pub(crate) fn try_new_allocation<'tcx>( ty: rustc_middle::ty::Ty<'tcx>, - const_value: ConstValue<'tcx>, + const_value: ConstValue, tables: &mut Tables<'tcx, BridgeTys>, cx: &CompilerCtxt<'tcx, BridgeTys>, ) -> Result<Allocation, Error> { @@ -54,8 +54,8 @@ pub(crate) fn try_new_allocation<'tcx>( alloc::try_new_scalar(layout, scalar, cx).map(|alloc| alloc.stable(tables, cx)) } ConstValue::ZeroSized => Ok(new_empty_allocation(layout.align.abi)), - ConstValue::Slice { data, meta } => { - alloc::try_new_slice(layout, data, meta, cx).map(|alloc| alloc.stable(tables, cx)) + ConstValue::Slice { alloc_id, meta } => { + alloc::try_new_slice(layout, alloc_id, meta, cx).map(|alloc| alloc.stable(tables, cx)) } ConstValue::Indirect { alloc_id, offset } => { let alloc = alloc::try_new_indirect(alloc_id, cx); |
