Skip to content

Commit 4ba01da

Browse files
committed
add fast-path for wide pointers
1 parent 472364c commit 4ba01da

File tree

1 file changed

+8
-1
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+8
-1
lines changed

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::assert_matches::assert_matches;
66

77
use either::{Either, Left, Right};
88
use rustc_abi::{BackendRepr, HasDataLayout, Size};
9-
use rustc_middle::ty::Ty;
109
use rustc_middle::ty::layout::TyAndLayout;
10+
use rustc_middle::ty::{self, Ty};
1111
use rustc_middle::{bug, mir, span_bug};
1212
use tracing::field::Empty;
1313
use tracing::{instrument, trace};
@@ -889,6 +889,13 @@ where
889889
// padding in the target independent of layout choices.
890890
let src_has_padding = match src.layout().backend_repr {
891891
BackendRepr::Scalar(_) => false,
892+
BackendRepr::ScalarPair(left, right)
893+
if matches!(src.layout().ty.kind(), ty::Ref(..) | ty::RawPtr(..)) =>
894+
{
895+
// Wide pointers never have padding, so we can avoid calling `size()`.
896+
debug_assert_eq!(left.size(self) + right.size(self), src.layout().size);
897+
false
898+
}
892899
BackendRepr::ScalarPair(left, right) => {
893900
let left_size = left.size(self);
894901
let right_size = right.size(self);

0 commit comments

Comments
 (0)