Skip to content

Commit d57b755

Browse files
committed
Use WrappingRange::full instead of hand-rolling it
1 parent 09b291f commit d57b755

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

compiler/rustc_codegen_gcc/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
328328
interpret::Pointer::new(alloc_id, Size::from_bytes(ptr_offset)),
329329
&cx.tcx,
330330
),
331-
abi::Scalar::Initialized { value: Primitive::Pointer, valid_range: WrappingRange { start: 0, end: !0 } },
331+
abi::Scalar::Initialized { value: Primitive::Pointer, valid_range: WrappingRange::full(dl.pointer_size) },
332332
cx.type_i8p(),
333333
));
334334
next_offset = offset + pointer_size;

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
111111
),
112112
Scalar::Initialized {
113113
value: Primitive::Pointer,
114-
valid_range: WrappingRange { start: 0, end: !0 },
114+
valid_range: WrappingRange::full(dl.pointer_size),
115115
},
116116
cx.type_i8p_ext(address_space),
117117
));

compiler/rustc_middle/src/ty/layout.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
567567
let scalar_unit = |value: Primitive| {
568568
let size = value.size(dl);
569569
assert!(size.bits() <= 128);
570-
Scalar::Initialized {
571-
value,
572-
valid_range: WrappingRange { start: 0, end: size.unsigned_int_max() },
573-
}
570+
Scalar::Initialized { value, valid_range: WrappingRange::full(size) }
574571
};
575572
let scalar =
576573
|value: Primitive| tcx.intern_layout(LayoutS::scalar(self, scalar_unit(value)));

0 commit comments

Comments
 (0)