Iron out last rustc-specific details
This commit is contained in:
parent
cb622f3994
commit
42f4393824
5 changed files with 43 additions and 18 deletions
|
@ -156,7 +156,6 @@ use smallvec::SmallVec;
|
|||
|
||||
use rustc_apfloat::ieee::{DoubleS, IeeeFloat, SingleS};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::RangeEnd;
|
||||
use rustc_index::IndexVec;
|
||||
|
||||
use self::Constructor::*;
|
||||
|
@ -173,6 +172,21 @@ enum Presence {
|
|||
Seen,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum RangeEnd {
|
||||
Included,
|
||||
Excluded,
|
||||
}
|
||||
|
||||
impl fmt::Display for RangeEnd {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(match self {
|
||||
RangeEnd::Included => "..=",
|
||||
RangeEnd::Excluded => "..",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// A possibly infinite integer. Values are encoded such that the ordering on `u128` matches the
|
||||
/// natural order on the original type. For example, `-128i8` is encoded as `0` and `127i8` as
|
||||
/// `255`. See `signed_bias` for details.
|
||||
|
@ -220,7 +234,7 @@ impl MaybeInfiniteInt {
|
|||
match self {
|
||||
Finite(n) => match n.checked_sub(1) {
|
||||
Some(m) => Finite(m),
|
||||
None => bug!(),
|
||||
None => panic!("Called `MaybeInfiniteInt::minus_one` on 0"),
|
||||
},
|
||||
JustAfterMax => Finite(u128::MAX),
|
||||
x => x,
|
||||
|
@ -233,7 +247,7 @@ impl MaybeInfiniteInt {
|
|||
Some(m) => Finite(m),
|
||||
None => JustAfterMax,
|
||||
},
|
||||
JustAfterMax => bug!(),
|
||||
JustAfterMax => panic!("Called `MaybeInfiniteInt::plus_one` on u128::MAX+1"),
|
||||
x => x,
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +284,7 @@ impl IntRange {
|
|||
}
|
||||
if lo >= hi {
|
||||
// This should have been caught earlier by E0030.
|
||||
bug!("malformed range pattern: {lo:?}..{hi:?}");
|
||||
panic!("malformed range pattern: {lo:?}..{hi:?}");
|
||||
}
|
||||
IntRange { lo, hi }
|
||||
}
|
||||
|
@ -431,7 +445,7 @@ impl Slice {
|
|||
let kind = match (array_len, kind) {
|
||||
// If the middle `..` has length 0, we effectively have a fixed-length pattern.
|
||||
(Some(len), VarLen(prefix, suffix)) if prefix + suffix == len => FixedLen(len),
|
||||
(Some(len), VarLen(prefix, suffix)) if prefix + suffix > len => bug!(
|
||||
(Some(len), VarLen(prefix, suffix)) if prefix + suffix > len => panic!(
|
||||
"Slice pattern of length {} longer than its array length {len}",
|
||||
prefix + suffix
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue