Struct rustc_mir_build::thir::pattern::deconstruct_pat::IntRange [−][src]
pub(super) struct IntRange {
range: RangeInclusive<u128>,
bias: 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>
bias: u128
Keeps the bias used for encoding the range. It depends on the type of the range and
possibly the pointer size of the current architecture. The algorithm ensures we never
compare IntRange
s with different types/architectures.
Implementations
fn from_const<'tcx>(
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
value: &Const<'tcx>
) -> Option<IntRange>
fn from_range<'tcx>(
tcx: TyCtxt<'tcx>,
lo: u128,
hi: u128,
ty: Ty<'tcx>,
end: &RangeEnd
) -> Option<IntRange>
Only used for displaying the range properly.
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,
hir_id: 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,
hir_id: HirId
)
Lint on likely incorrect range patterns (#63987)
See Constructor::is_covered_by
Trait Implementations
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.
Auto Trait Implementations
impl RefUnwindSafe for IntRange
impl UnwindSafe for IntRange
Blanket Implementations
Mutably borrows from an owned value. Read more
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: 56 bytes