Skip to content

Commit e8e6d9b

Browse files
committed
Rename to WrappingRange
1 parent 7043395 commit e8e6d9b

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_middle::mir::mono::MonoItem;
1717
use rustc_middle::ty::{self, Instance, Ty};
1818
use rustc_middle::{bug, span_bug};
1919
use rustc_target::abi::{
20-
AddressSpace, Align, AllocationRange, HasDataLayout, LayoutOf, Primitive, Scalar, Size,
20+
AddressSpace, Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size, WrappingRange,
2121
};
2222
use tracing::debug;
2323

@@ -61,10 +61,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
6161
Pointer::new(alloc_id, Size::from_bytes(ptr_offset)),
6262
&cx.tcx,
6363
),
64-
&Scalar {
65-
value: Primitive::Pointer,
66-
valid_range: AllocationRange { start: 0, end: !0 },
67-
},
64+
&Scalar { value: Primitive::Pointer, valid_range: WrappingRange { start: 0, end: !0 } },
6865
cx.type_i8p_ext(address_space),
6966
));
7067
next_offset = offset + pointer_size;

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
499499
let scalar_unit = |value: Primitive| {
500500
let bits = value.size(dl).bits();
501501
assert!(bits <= 128);
502-
Scalar { value, valid_range: AllocationRange { start: 0, end: (!0 >> (128 - bits)) } }
502+
Scalar { value, valid_range: WrappingRange { start: 0, end: (!0 >> (128 - bits)) } }
503503
};
504504
let scalar = |value: Primitive| tcx.intern_layout(Layout::scalar(self, scalar_unit(value)));
505505

@@ -512,13 +512,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
512512
// Basic scalars.
513513
ty::Bool => tcx.intern_layout(Layout::scalar(
514514
self,
515-
Scalar { value: Int(I8, false), valid_range: AllocationRange { start: 0, end: 1 } },
515+
Scalar { value: Int(I8, false), valid_range: WrappingRange { start: 0, end: 1 } },
516516
)),
517517
ty::Char => tcx.intern_layout(Layout::scalar(
518518
self,
519519
Scalar {
520520
value: Int(I32, false),
521-
valid_range: AllocationRange { start: 0, end: 0x10FFFF },
521+
valid_range: WrappingRange { start: 0, end: 0x10FFFF },
522522
},
523523
)),
524524
ty::Int(ity) => scalar(Int(Integer::from_int_ty(dl, ity), true)),
@@ -529,7 +529,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
529529
}),
530530
ty::FnPtr(_) => {
531531
let mut ptr = scalar_unit(Pointer);
532-
ptr.valid_range = AllocationRange { start: 1, end: ptr.valid_range.end };
532+
ptr.valid_range = WrappingRange { start: 1, end: ptr.valid_range.end };
533533
tcx.intern_layout(Layout::scalar(self, ptr))
534534
}
535535

@@ -548,7 +548,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
548548
let mut data_ptr = scalar_unit(Pointer);
549549
if !ty.is_unsafe_ptr() {
550550
data_ptr.valid_range =
551-
AllocationRange { start: 1, end: data_ptr.valid_range.end };
551+
WrappingRange { start: 1, end: data_ptr.valid_range.end };
552552
}
553553

554554
let pointee = tcx.normalize_erasing_regions(param_env, pointee);
@@ -565,7 +565,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
565565
ty::Dynamic(..) => {
566566
let mut vtable = scalar_unit(Pointer);
567567
vtable.valid_range =
568-
AllocationRange { start: 1, end: vtable.valid_range.end };
568+
WrappingRange { start: 1, end: vtable.valid_range.end };
569569
vtable
570570
}
571571
_ => return Err(LayoutError::Unknown(unsized_part)),
@@ -1261,7 +1261,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12611261
let tag_mask = !0u128 >> (128 - ity.size().bits());
12621262
let tag = Scalar {
12631263
value: Int(ity, signed),
1264-
valid_range: AllocationRange {
1264+
valid_range: WrappingRange {
12651265
start: (min as u128 & tag_mask),
12661266
end: (max as u128 & tag_mask),
12671267
},
@@ -1545,7 +1545,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15451545
let discr_int_ty = discr_int.to_ty(tcx, false);
15461546
let tag = Scalar {
15471547
value: Primitive::Int(discr_int, false),
1548-
valid_range: AllocationRange { start: 0, end: max_discr },
1548+
valid_range: WrappingRange { start: 0, end: max_discr },
15491549
};
15501550
let tag_layout = self.tcx.intern_layout(Layout::scalar(self, tag.clone()));
15511551
let tag_layout = TyAndLayout { ty: discr_int_ty, layout: tag_layout };

compiler/rustc_mir/src/interpret/validity.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty;
1515
use rustc_middle::ty::layout::TyAndLayout;
1616
use rustc_span::symbol::{sym, Symbol};
1717
use rustc_target::abi::{
18-
Abi, AllocationRange, LayoutOf, Scalar as ScalarAbi, Size, VariantIdx, Variants,
18+
Abi, LayoutOf, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange,
1919
};
2020

2121
use std::hash::Hash;
@@ -184,8 +184,8 @@ fn write_path(out: &mut String, path: &[PathElem]) {
184184

185185
// Formats such that a sentence like "expected something {}" to mean
186186
// "expected something <in the given range>" makes sense.
187-
fn wrapping_range_format(r: AllocationRange, max_hi: u128) -> String {
188-
let AllocationRange { start: lo, end: hi } = r;
187+
fn wrapping_range_format(r: WrappingRange, max_hi: u128) -> String {
188+
let WrappingRange { start: lo, end: hi } = r;
189189
assert!(hi <= max_hi);
190190
if lo > hi {
191191
format!("less or equal to {}, or greater or equal to {}", hi, lo)
@@ -624,7 +624,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
624624
) -> InterpResult<'tcx> {
625625
let value = self.read_scalar(op)?;
626626
let valid_range = scalar_layout.valid_range.clone();
627-
let AllocationRange { start: lo, end: hi } = valid_range;
627+
let WrappingRange { start: lo, end: hi } = valid_range;
628628
// Determine the allowed range
629629
// `max_hi` is as big as the size fits
630630
let max_hi = u128::MAX >> (128 - op.layout.size.bits());

compiler/rustc_target/src/abi/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -690,12 +690,12 @@ impl Primitive {
690690
/// semantics.
691691
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
692692
#[derive(HashStable_Generic)]
693-
pub struct AllocationRange {
693+
pub struct WrappingRange {
694694
pub start: u128,
695695
pub end: u128,
696696
}
697697

698-
impl AllocationRange {
698+
impl WrappingRange {
699699
/// Returns `true` if `v` is contained in the range.
700700
#[inline]
701701
pub fn contains(&self, v: u128) -> bool {
@@ -723,13 +723,13 @@ pub struct Scalar {
723723
// FIXME(eddyb) always use the shortest range, e.g., by finding
724724
// the largest space between two consecutive valid values and
725725
// taking everything else as the (shortest) valid range.
726-
pub valid_range: AllocationRange,
726+
pub valid_range: WrappingRange,
727727
}
728728

729729
impl Scalar {
730730
pub fn is_bool(&self) -> bool {
731731
matches!(self.value, Int(I8, false))
732-
&& matches!(self.valid_range, AllocationRange { start: 0, end: 1 })
732+
&& matches!(self.valid_range, WrappingRange { start: 0, end: 1 })
733733
}
734734

735735
/// Returns the valid range as a `x..y` range.
@@ -1022,7 +1022,7 @@ impl Niche {
10221022
return None;
10231023
}
10241024

1025-
Some((start, Scalar { value, valid_range: AllocationRange { start: v.start, end } }))
1025+
Some((start, Scalar { value, valid_range: WrappingRange { start: v.start, end } }))
10261026
}
10271027
}
10281028

0 commit comments

Comments
 (0)