Use WrappingRange::full instead of hand-rolling it

This commit is contained in:
Oli Scherer 2022-04-05 13:13:21 +00:00
parent 09b291f0b2
commit d57b755909
3 changed files with 3 additions and 6 deletions

View file

@ -328,7 +328,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
interpret::Pointer::new(alloc_id, Size::from_bytes(ptr_offset)),
&cx.tcx,
),
abi::Scalar::Initialized { value: Primitive::Pointer, valid_range: WrappingRange { start: 0, end: !0 } },
abi::Scalar::Initialized { value: Primitive::Pointer, valid_range: WrappingRange::full(dl.pointer_size) },
cx.type_i8p(),
));
next_offset = offset + pointer_size;

View file

@ -111,7 +111,7 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
),
Scalar::Initialized {
value: Primitive::Pointer,
valid_range: WrappingRange { start: 0, end: !0 },
valid_range: WrappingRange::full(dl.pointer_size),
},
cx.type_i8p_ext(address_space),
));

View file

@ -567,10 +567,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let scalar_unit = |value: Primitive| {
let size = value.size(dl);
assert!(size.bits() <= 128);
Scalar::Initialized {
value,
valid_range: WrappingRange { start: 0, end: size.unsigned_int_max() },
}
Scalar::Initialized { value, valid_range: WrappingRange::full(size) }
};
let scalar =
|value: Primitive| tcx.intern_layout(LayoutS::scalar(self, scalar_unit(value)));