Struct rustc_mir_build::thir::pattern::deconstruct_pat::IntRange
source · pub(crate) struct IntRange {
range: RangeInclusive<u128>,
}
Expand description
An inclusive interval, used for precise integer exhaustiveness checking.
IntRange
s always store a contiguous range. This means that values are
encoded such that 0
encodes the minimum value for the integer,
regardless of the signedness.
For example, the pattern -128..=127i8
is encoded as 0..=255
.
This makes comparisons and arithmetic on interval endpoints much more
straightforward. See signed_bias
for details.
IntRange
is never used to encode an empty range or a “range” that wraps
around the (offset) space: i.e., range.lo <= range.hi
.
Fields§
§range: RangeInclusive<u128>
Implementations§
source§impl IntRange
impl IntRange
fn is_integral(ty: Ty<'_>) -> bool
fn is_singleton(&self) -> bool
fn boundaries(&self) -> (u128, u128)
fn from_bits<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, bits: u128) -> IntRange
fn from_range<'tcx>( tcx: TyCtxt<'tcx>, lo: u128, hi: u128, ty: Ty<'tcx>, end: RangeEnd ) -> IntRange
fn signed_bias(tcx: TyCtxt<'_>, ty: Ty<'_>) -> u128
fn is_subrange(&self, other: &Self) -> bool
fn intersection(&self, other: &Self) -> Option<Self>
fn suspicious_intersection(&self, other: &Self) -> bool
sourcefn to_pat<'tcx>(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Pat<'tcx>
fn to_pat<'tcx>(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Pat<'tcx>
Only used for displaying the range properly.
sourcepub(super) fn lint_overlapping_range_endpoints<'a, 'p: 'a, 'tcx: 'a>(
&self,
pcx: &PatCtxt<'_, 'p, 'tcx>,
pats: impl Iterator<Item = &'a DeconstructedPat<'p, 'tcx>>,
column_count: usize,
lint_root: HirId
)
pub(super) fn lint_overlapping_range_endpoints<'a, 'p: 'a, 'tcx: 'a>( &self, pcx: &PatCtxt<'_, 'p, 'tcx>, pats: impl Iterator<Item = &'a DeconstructedPat<'p, 'tcx>>, column_count: usize, lint_root: HirId )
Lint on likely incorrect range patterns (#63987)
sourcefn is_covered_by(&self, other: &Self) -> bool
fn is_covered_by(&self, other: &Self) -> bool
See Constructor::is_covered_by
Trait Implementations§
source§impl Debug for IntRange
impl Debug for IntRange
Note: this is often not what we want: e.g. false
is converted into the range 0..=0
and
would be displayed as such. To render properly, convert to a pattern first.
source§impl PartialEq<IntRange> for IntRange
impl PartialEq<IntRange> for IntRange
impl Eq for IntRange
impl StructuralEq for IntRange
impl StructuralPartialEq for IntRange
Auto Trait Implementations§
impl RefUnwindSafe for IntRange
impl Send for IntRange
impl Sync for IntRange
impl Unpin for IntRange
impl UnwindSafe for IntRange
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes