Cleanup macro-expanded code in rustc_type_ir
This commit is contained in:
parent
1ef685ea39
commit
07fbb1b372
2 changed files with 189 additions and 367 deletions
|
@ -274,7 +274,7 @@ impl Ord for DefId {
|
||||||
impl PartialOrd for DefId {
|
impl PartialOrd for DefId {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &DefId) -> Option<std::cmp::Ordering> {
|
fn partial_cmp(&self, other: &DefId) -> Option<std::cmp::Ordering> {
|
||||||
Some(Ord::cmp(self, other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,61 +301,37 @@ impl<I: Interner> Clone for TyKind<I> {
|
||||||
impl<I: Interner> PartialEq for TyKind<I> {
|
impl<I: Interner> PartialEq for TyKind<I> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &TyKind<I>) -> bool {
|
fn eq(&self, other: &TyKind<I>) -> bool {
|
||||||
let __self_vi = tykind_discriminant(self);
|
tykind_discriminant(self) == tykind_discriminant(other)
|
||||||
let __arg_1_vi = tykind_discriminant(other);
|
&& match (self, other) {
|
||||||
if __self_vi == __arg_1_vi {
|
(Int(a_i), Int(b_i)) => a_i == b_i,
|
||||||
match (&*self, &*other) {
|
(Uint(a_u), Uint(b_u)) => a_u == b_u,
|
||||||
(&Int(ref __self_0), &Int(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
(Float(a_f), Float(b_f)) => a_f == b_f,
|
||||||
(&Uint(ref __self_0), &Uint(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
(Adt(a_d, a_s), Adt(b_d, b_s)) => a_d == b_d && a_s == b_s,
|
||||||
(&Float(ref __self_0), &Float(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
(Foreign(a_d), Foreign(b_d)) => a_d == b_d,
|
||||||
(&Adt(ref __self_0, ref __self_1), &Adt(ref __arg_1_0, ref __arg_1_1)) => {
|
(Array(a_t, a_c), Array(b_t, b_c)) => a_t == b_t && a_c == b_c,
|
||||||
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
|
(Slice(a_t), Slice(b_t)) => a_t == b_t,
|
||||||
|
(RawPtr(a_t), RawPtr(b_t)) => a_t == b_t,
|
||||||
|
(Ref(a_r, a_t, a_m), Ref(b_r, b_t, b_m)) => a_r == b_r && a_t == b_t && a_m == b_m,
|
||||||
|
(FnDef(a_d, a_s), FnDef(b_d, b_s)) => a_d == b_d && a_s == b_s,
|
||||||
|
(FnPtr(a_s), FnPtr(b_s)) => a_s == b_s,
|
||||||
|
(Dynamic(a_p, a_r, a_repr), Dynamic(b_p, b_r, b_repr)) => {
|
||||||
|
a_p == b_p && a_r == b_r && a_repr == b_repr
|
||||||
}
|
}
|
||||||
(&Foreign(ref __self_0), &Foreign(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
(Closure(a_d, a_s), Closure(b_d, b_s)) => a_d == b_d && a_s == b_s,
|
||||||
(&Array(ref __self_0, ref __self_1), &Array(ref __arg_1_0, ref __arg_1_1)) => {
|
(Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => {
|
||||||
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
|
a_d == b_d && a_s == b_s && a_m == b_m
|
||||||
}
|
}
|
||||||
(&Slice(ref __self_0), &Slice(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
(GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g == b_g,
|
||||||
(&RawPtr(ref __self_0), &RawPtr(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
(Tuple(a_t), Tuple(b_t)) => a_t == b_t,
|
||||||
(
|
(Projection(a_p), Projection(b_p)) => a_p == b_p,
|
||||||
&Ref(ref __self_0, ref __self_1, ref __self_2),
|
(Opaque(a_d, a_s), Opaque(b_d, b_s)) => a_d == b_d && a_s == b_s,
|
||||||
&Ref(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
|
(Param(a_p), Param(b_p)) => a_p == b_p,
|
||||||
) => __self_0 == __arg_1_0 && __self_1 == __arg_1_1 && __self_2 == __arg_1_2,
|
(Bound(a_d, a_b), Bound(b_d, b_b)) => a_d == b_d && a_b == b_b,
|
||||||
(&FnDef(ref __self_0, ref __self_1), &FnDef(ref __arg_1_0, ref __arg_1_1)) => {
|
(Placeholder(a_p), Placeholder(b_p)) => a_p == b_p,
|
||||||
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
|
(Infer(a_t), Infer(b_t)) => a_t == b_t,
|
||||||
}
|
(Error(a_e), Error(b_e)) => a_e == b_e,
|
||||||
(&FnPtr(ref __self_0), &FnPtr(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
_ => true, // unreachable
|
||||||
(
|
|
||||||
&Dynamic(ref __self_0, ref __self_1, ref self_repr),
|
|
||||||
&Dynamic(ref __arg_1_0, ref __arg_1_1, ref arg_repr),
|
|
||||||
) => __self_0 == __arg_1_0 && __self_1 == __arg_1_1 && self_repr == arg_repr,
|
|
||||||
(&Closure(ref __self_0, ref __self_1), &Closure(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
|
|
||||||
}
|
|
||||||
(
|
|
||||||
&Generator(ref __self_0, ref __self_1, ref __self_2),
|
|
||||||
&Generator(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
|
|
||||||
) => __self_0 == __arg_1_0 && __self_1 == __arg_1_1 && __self_2 == __arg_1_2,
|
|
||||||
(&GeneratorWitness(ref __self_0), &GeneratorWitness(ref __arg_1_0)) => {
|
|
||||||
__self_0 == __arg_1_0
|
|
||||||
}
|
|
||||||
(&Tuple(ref __self_0), &Tuple(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&Projection(ref __self_0), &Projection(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&Opaque(ref __self_0, ref __self_1), &Opaque(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
|
|
||||||
}
|
|
||||||
(&Param(ref __self_0), &Param(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&Bound(ref __self_0, ref __self_1), &Bound(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
|
|
||||||
}
|
|
||||||
(&Placeholder(ref __self_0), &Placeholder(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&Infer(ref __self_0), &Infer(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&Error(ref __self_0), &Error(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
_ => true,
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +342,7 @@ impl<I: Interner> Eq for TyKind<I> {}
|
||||||
impl<I: Interner> PartialOrd for TyKind<I> {
|
impl<I: Interner> PartialOrd for TyKind<I> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &TyKind<I>) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &TyKind<I>) -> Option<Ordering> {
|
||||||
Some(Ord::cmp(self, other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,213 +350,102 @@ impl<I: Interner> PartialOrd for TyKind<I> {
|
||||||
impl<I: Interner> Ord for TyKind<I> {
|
impl<I: Interner> Ord for TyKind<I> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &TyKind<I>) -> Ordering {
|
fn cmp(&self, other: &TyKind<I>) -> Ordering {
|
||||||
let __self_vi = tykind_discriminant(self);
|
tykind_discriminant(self).cmp(&tykind_discriminant(other)).then_with(|| {
|
||||||
let __arg_1_vi = tykind_discriminant(other);
|
match (self, other) {
|
||||||
if __self_vi == __arg_1_vi {
|
(Int(a_i), Int(b_i)) => a_i.cmp(b_i),
|
||||||
match (&*self, &*other) {
|
(Uint(a_u), Uint(b_u)) => a_u.cmp(b_u),
|
||||||
(&Int(ref __self_0), &Int(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(Float(a_f), Float(b_f)) => a_f.cmp(b_f),
|
||||||
(&Uint(ref __self_0), &Uint(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(Adt(a_d, a_s), Adt(b_d, b_s)) => a_d.cmp(b_d).then_with(|| a_s.cmp(b_s)),
|
||||||
(&Float(ref __self_0), &Float(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(Foreign(a_d), Foreign(b_d)) => a_d.cmp(b_d),
|
||||||
(&Adt(ref __self_0, ref __self_1), &Adt(ref __arg_1_0, ref __arg_1_1)) => {
|
(Array(a_t, a_c), Array(b_t, b_c)) => a_t.cmp(b_t).then_with(|| a_c.cmp(b_c)),
|
||||||
match Ord::cmp(__self_0, __arg_1_0) {
|
(Slice(a_t), Slice(b_t)) => a_t.cmp(b_t),
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
(RawPtr(a_t), RawPtr(b_t)) => a_t.cmp(b_t),
|
||||||
cmp => cmp,
|
(Ref(a_r, a_t, a_m), Ref(b_r, b_t, b_m)) => {
|
||||||
}
|
a_r.cmp(b_r).then_with(|| a_t.cmp(b_t).then_with(|| a_m.cmp(b_m)))
|
||||||
}
|
}
|
||||||
(&Foreign(ref __self_0), &Foreign(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(FnDef(a_d, a_s), FnDef(b_d, b_s)) => a_d.cmp(b_d).then_with(|| a_s.cmp(b_s)),
|
||||||
(&Array(ref __self_0, ref __self_1), &Array(ref __arg_1_0, ref __arg_1_1)) => {
|
(FnPtr(a_s), FnPtr(b_s)) => a_s.cmp(b_s),
|
||||||
match Ord::cmp(__self_0, __arg_1_0) {
|
(Dynamic(a_p, a_r, a_repr), Dynamic(b_p, b_r, b_repr)) => {
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
a_p.cmp(b_p).then_with(|| a_r.cmp(b_r).then_with(|| a_repr.cmp(b_repr)))
|
||||||
cmp => cmp,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
(&Slice(ref __self_0), &Slice(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(Closure(a_p, a_s), Closure(b_p, b_s)) => a_p.cmp(b_p).then_with(|| a_s.cmp(b_s)),
|
||||||
(&RawPtr(ref __self_0), &RawPtr(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => {
|
||||||
(
|
a_d.cmp(b_d).then_with(|| a_s.cmp(b_s).then_with(|| a_m.cmp(b_m)))
|
||||||
&Ref(ref __self_0, ref __self_1, ref __self_2),
|
|
||||||
&Ref(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
|
|
||||||
) => match Ord::cmp(__self_0, __arg_1_0) {
|
|
||||||
Ordering::Equal => match Ord::cmp(__self_1, __arg_1_1) {
|
|
||||||
Ordering::Equal => Ord::cmp(__self_2, __arg_1_2),
|
|
||||||
cmp => cmp,
|
|
||||||
},
|
|
||||||
cmp => cmp,
|
|
||||||
},
|
|
||||||
(&FnDef(ref __self_0, ref __self_1), &FnDef(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
match Ord::cmp(__self_0, __arg_1_0) {
|
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
|
||||||
cmp => cmp,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
(&FnPtr(ref __self_0), &FnPtr(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
(GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g.cmp(b_g),
|
||||||
(
|
(Tuple(a_t), Tuple(b_t)) => a_t.cmp(b_t),
|
||||||
&Dynamic(ref __self_0, ref __self_1, ref self_repr),
|
(Projection(a_p), Projection(b_p)) => a_p.cmp(b_p),
|
||||||
&Dynamic(ref __arg_1_0, ref __arg_1_1, ref arg_repr),
|
(Opaque(a_d, a_s), Opaque(b_d, b_s)) => a_d.cmp(b_d).then_with(|| a_s.cmp(b_s)),
|
||||||
) => match Ord::cmp(__self_0, __arg_1_0) {
|
(Param(a_p), Param(b_p)) => a_p.cmp(b_p),
|
||||||
Ordering::Equal => match Ord::cmp(__self_1, __arg_1_1) {
|
(Bound(a_d, a_b), Bound(b_d, b_b)) => a_d.cmp(b_d).then_with(|| a_b.cmp(b_b)),
|
||||||
Ordering::Equal => Ord::cmp(self_repr, arg_repr),
|
(Placeholder(a_p), Placeholder(b_p)) => a_p.cmp(b_p),
|
||||||
cmp => cmp,
|
(Infer(a_t), Infer(b_t)) => a_t.cmp(b_t),
|
||||||
},
|
(Error(a_e), Error(b_e)) => a_e.cmp(b_e),
|
||||||
cmp => cmp,
|
_ => Ordering::Equal, // unreachable
|
||||||
},
|
|
||||||
(&Closure(ref __self_0, ref __self_1), &Closure(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
match Ord::cmp(__self_0, __arg_1_0) {
|
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
|
||||||
cmp => cmp,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(
|
|
||||||
&Generator(ref __self_0, ref __self_1, ref __self_2),
|
|
||||||
&Generator(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
|
|
||||||
) => match Ord::cmp(__self_0, __arg_1_0) {
|
|
||||||
Ordering::Equal => match Ord::cmp(__self_1, __arg_1_1) {
|
|
||||||
Ordering::Equal => Ord::cmp(__self_2, __arg_1_2),
|
|
||||||
cmp => cmp,
|
|
||||||
},
|
|
||||||
cmp => cmp,
|
|
||||||
},
|
|
||||||
(&GeneratorWitness(ref __self_0), &GeneratorWitness(ref __arg_1_0)) => {
|
|
||||||
Ord::cmp(__self_0, __arg_1_0)
|
|
||||||
}
|
|
||||||
(&Tuple(ref __self_0), &Tuple(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
|
||||||
(&Projection(ref __self_0), &Projection(ref __arg_1_0)) => {
|
|
||||||
Ord::cmp(__self_0, __arg_1_0)
|
|
||||||
}
|
|
||||||
(&Opaque(ref __self_0, ref __self_1), &Opaque(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
match Ord::cmp(__self_0, __arg_1_0) {
|
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
|
||||||
cmp => cmp,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(&Param(ref __self_0), &Param(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
|
||||||
(&Bound(ref __self_0, ref __self_1), &Bound(ref __arg_1_0, ref __arg_1_1)) => {
|
|
||||||
match Ord::cmp(__self_0, __arg_1_0) {
|
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
|
||||||
cmp => cmp,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(&Placeholder(ref __self_0), &Placeholder(ref __arg_1_0)) => {
|
|
||||||
Ord::cmp(__self_0, __arg_1_0)
|
|
||||||
}
|
|
||||||
(&Infer(ref __self_0), &Infer(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
|
||||||
(&Error(ref __self_0), &Error(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
|
||||||
_ => Ordering::Equal,
|
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
Ord::cmp(&__self_vi, &__arg_1_vi)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is manually implemented because a derive would require `I: Hash`
|
// This is manually implemented because a derive would require `I: Hash`
|
||||||
impl<I: Interner> hash::Hash for TyKind<I> {
|
impl<I: Interner> hash::Hash for TyKind<I> {
|
||||||
fn hash<__H: hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
match (&*self,) {
|
tykind_discriminant(self).hash(state);
|
||||||
(&Int(ref __self_0),) => {
|
match self {
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
Int(i) => i.hash(state),
|
||||||
hash::Hash::hash(__self_0, state)
|
Uint(u) => u.hash(state),
|
||||||
|
Float(f) => f.hash(state),
|
||||||
|
Adt(d, s) => {
|
||||||
|
d.hash(state);
|
||||||
|
s.hash(state)
|
||||||
}
|
}
|
||||||
(&Uint(ref __self_0),) => {
|
Foreign(d) => d.hash(state),
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
Array(t, c) => {
|
||||||
hash::Hash::hash(__self_0, state)
|
t.hash(state);
|
||||||
|
c.hash(state)
|
||||||
}
|
}
|
||||||
(&Float(ref __self_0),) => {
|
Slice(t) => t.hash(state),
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
RawPtr(t) => t.hash(state),
|
||||||
hash::Hash::hash(__self_0, state)
|
Ref(r, t, m) => {
|
||||||
|
r.hash(state);
|
||||||
|
t.hash(state);
|
||||||
|
m.hash(state)
|
||||||
}
|
}
|
||||||
(&Adt(ref __self_0, ref __self_1),) => {
|
FnDef(d, s) => {
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
d.hash(state);
|
||||||
hash::Hash::hash(__self_0, state);
|
s.hash(state)
|
||||||
hash::Hash::hash(__self_1, state)
|
|
||||||
}
|
}
|
||||||
(&Foreign(ref __self_0),) => {
|
FnPtr(s) => s.hash(state),
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
Dynamic(p, r, repr) => {
|
||||||
hash::Hash::hash(__self_0, state)
|
p.hash(state);
|
||||||
|
r.hash(state);
|
||||||
|
repr.hash(state)
|
||||||
}
|
}
|
||||||
(&Array(ref __self_0, ref __self_1),) => {
|
Closure(d, s) => {
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
d.hash(state);
|
||||||
hash::Hash::hash(__self_0, state);
|
s.hash(state)
|
||||||
hash::Hash::hash(__self_1, state)
|
|
||||||
}
|
}
|
||||||
(&Slice(ref __self_0),) => {
|
Generator(d, s, m) => {
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
d.hash(state);
|
||||||
hash::Hash::hash(__self_0, state)
|
s.hash(state);
|
||||||
|
m.hash(state)
|
||||||
}
|
}
|
||||||
(&RawPtr(ref __self_0),) => {
|
GeneratorWitness(g) => g.hash(state),
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
Tuple(t) => t.hash(state),
|
||||||
hash::Hash::hash(__self_0, state)
|
Projection(p) => p.hash(state),
|
||||||
|
Opaque(d, s) => {
|
||||||
|
d.hash(state);
|
||||||
|
s.hash(state)
|
||||||
}
|
}
|
||||||
(&Ref(ref __self_0, ref __self_1, ref __self_2),) => {
|
Param(p) => p.hash(state),
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
Bound(d, b) => {
|
||||||
hash::Hash::hash(__self_0, state);
|
d.hash(state);
|
||||||
hash::Hash::hash(__self_1, state);
|
b.hash(state)
|
||||||
hash::Hash::hash(__self_2, state)
|
|
||||||
}
|
}
|
||||||
(&FnDef(ref __self_0, ref __self_1),) => {
|
Placeholder(p) => p.hash(state),
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
Infer(t) => t.hash(state),
|
||||||
hash::Hash::hash(__self_0, state);
|
Error(e) => e.hash(state),
|
||||||
hash::Hash::hash(__self_1, state)
|
Bool | Char | Str | Never => (),
|
||||||
}
|
|
||||||
(&FnPtr(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Dynamic(ref __self_0, ref __self_1, ref repr),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state);
|
|
||||||
hash::Hash::hash(__self_1, state);
|
|
||||||
hash::Hash::hash(repr, state)
|
|
||||||
}
|
|
||||||
(&Closure(ref __self_0, ref __self_1),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state);
|
|
||||||
hash::Hash::hash(__self_1, state)
|
|
||||||
}
|
|
||||||
(&Generator(ref __self_0, ref __self_1, ref __self_2),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state);
|
|
||||||
hash::Hash::hash(__self_1, state);
|
|
||||||
hash::Hash::hash(__self_2, state)
|
|
||||||
}
|
|
||||||
(&GeneratorWitness(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Tuple(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Projection(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Opaque(ref __self_0, ref __self_1),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state);
|
|
||||||
hash::Hash::hash(__self_1, state)
|
|
||||||
}
|
|
||||||
(&Param(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Bound(ref __self_0, ref __self_1),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state);
|
|
||||||
hash::Hash::hash(__self_1, state)
|
|
||||||
}
|
|
||||||
(&Placeholder(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Infer(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&Error(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(&tykind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
_ => hash::Hash::hash(&tykind_discriminant(self), state),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -588,37 +453,34 @@ impl<I: Interner> hash::Hash for TyKind<I> {
|
||||||
// This is manually implemented because a derive would require `I: Debug`
|
// This is manually implemented because a derive would require `I: Debug`
|
||||||
impl<I: Interner> fmt::Debug for TyKind<I> {
|
impl<I: Interner> fmt::Debug for TyKind<I> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
use std::fmt::*;
|
|
||||||
match self {
|
match self {
|
||||||
Bool => Formatter::write_str(f, "Bool"),
|
Bool => f.write_str("Bool"),
|
||||||
Char => Formatter::write_str(f, "Char"),
|
Char => f.write_str("Char"),
|
||||||
Int(f0) => Formatter::debug_tuple_field1_finish(f, "Int", f0),
|
Int(i) => f.debug_tuple_field1_finish("Int", i),
|
||||||
Uint(f0) => Formatter::debug_tuple_field1_finish(f, "Uint", f0),
|
Uint(u) => f.debug_tuple_field1_finish("Uint", u),
|
||||||
Float(f0) => Formatter::debug_tuple_field1_finish(f, "Float", f0),
|
Float(float) => f.debug_tuple_field1_finish("Float", float),
|
||||||
Adt(f0, f1) => Formatter::debug_tuple_field2_finish(f, "Adt", f0, f1),
|
Adt(d, s) => f.debug_tuple_field2_finish("Adt", d, s),
|
||||||
Foreign(f0) => Formatter::debug_tuple_field1_finish(f, "Foreign", f0),
|
Foreign(d) => f.debug_tuple_field1_finish("Foreign", d),
|
||||||
Str => Formatter::write_str(f, "Str"),
|
Str => f.write_str("Str"),
|
||||||
Array(f0, f1) => Formatter::debug_tuple_field2_finish(f, "Array", f0, f1),
|
Array(t, c) => f.debug_tuple_field2_finish("Array", t, c),
|
||||||
Slice(f0) => Formatter::debug_tuple_field1_finish(f, "Slice", f0),
|
Slice(t) => f.debug_tuple_field1_finish("Slice", t),
|
||||||
RawPtr(f0) => Formatter::debug_tuple_field1_finish(f, "RawPtr", f0),
|
RawPtr(t) => f.debug_tuple_field1_finish("RawPtr", t),
|
||||||
Ref(f0, f1, f2) => Formatter::debug_tuple_field3_finish(f, "Ref", f0, f1, f2),
|
Ref(r, t, m) => f.debug_tuple_field3_finish("Ref", r, t, m),
|
||||||
FnDef(f0, f1) => Formatter::debug_tuple_field2_finish(f, "FnDef", f0, f1),
|
FnDef(d, s) => f.debug_tuple_field2_finish("FnDef", d, s),
|
||||||
FnPtr(f0) => Formatter::debug_tuple_field1_finish(f, "FnPtr", f0),
|
FnPtr(s) => f.debug_tuple_field1_finish("FnPtr", s),
|
||||||
Dynamic(f0, f1, f2) => Formatter::debug_tuple_field3_finish(f, "Dynamic", f0, f1, f2),
|
Dynamic(p, r, repr) => f.debug_tuple_field3_finish("Dynamic", p, r, repr),
|
||||||
Closure(f0, f1) => Formatter::debug_tuple_field2_finish(f, "Closure", f0, f1),
|
Closure(d, s) => f.debug_tuple_field2_finish("Closure", d, s),
|
||||||
Generator(f0, f1, f2) => {
|
Generator(d, s, m) => f.debug_tuple_field3_finish("Generator", d, s, m),
|
||||||
Formatter::debug_tuple_field3_finish(f, "Generator", f0, f1, f2)
|
GeneratorWitness(g) => f.debug_tuple_field1_finish("GeneratorWitness", g),
|
||||||
}
|
Never => f.write_str("Never"),
|
||||||
GeneratorWitness(f0) => Formatter::debug_tuple_field1_finish(f, "GeneratorWitness", f0),
|
Tuple(t) => f.debug_tuple_field1_finish("Tuple", t),
|
||||||
Never => Formatter::write_str(f, "Never"),
|
Projection(p) => f.debug_tuple_field1_finish("Projection", p),
|
||||||
Tuple(f0) => Formatter::debug_tuple_field1_finish(f, "Tuple", f0),
|
Opaque(d, s) => f.debug_tuple_field2_finish("Opaque", d, s),
|
||||||
Projection(f0) => Formatter::debug_tuple_field1_finish(f, "Projection", f0),
|
Param(p) => f.debug_tuple_field1_finish("Param", p),
|
||||||
Opaque(f0, f1) => Formatter::debug_tuple_field2_finish(f, "Opaque", f0, f1),
|
Bound(d, b) => f.debug_tuple_field2_finish("Bound", d, b),
|
||||||
Param(f0) => Formatter::debug_tuple_field1_finish(f, "Param", f0),
|
Placeholder(p) => f.debug_tuple_field1_finish("Placeholder", p),
|
||||||
Bound(f0, f1) => Formatter::debug_tuple_field2_finish(f, "Bound", f0, f1),
|
Infer(t) => f.debug_tuple_field1_finish("Infer", t),
|
||||||
Placeholder(f0) => Formatter::debug_tuple_field1_finish(f, "Placeholder", f0),
|
TyKind::Error(e) => f.debug_tuple_field1_finish("Error", e),
|
||||||
Infer(f0) => Formatter::debug_tuple_field1_finish(f, "Infer", f0),
|
|
||||||
TyKind::Error(f0) => Formatter::debug_tuple_field1_finish(f, "Error", f0),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1091,12 +953,12 @@ where
|
||||||
impl<I: Interner> Clone for RegionKind<I> {
|
impl<I: Interner> Clone for RegionKind<I> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
ReEarlyBound(a) => ReEarlyBound(a.clone()),
|
ReEarlyBound(r) => ReEarlyBound(r.clone()),
|
||||||
ReLateBound(a, b) => ReLateBound(a.clone(), b.clone()),
|
ReLateBound(d, r) => ReLateBound(d.clone(), r.clone()),
|
||||||
ReFree(a) => ReFree(a.clone()),
|
ReFree(r) => ReFree(r.clone()),
|
||||||
ReStatic => ReStatic,
|
ReStatic => ReStatic,
|
||||||
ReVar(a) => ReVar(a.clone()),
|
ReVar(r) => ReVar(r.clone()),
|
||||||
RePlaceholder(a) => RePlaceholder(a.clone()),
|
RePlaceholder(r) => RePlaceholder(r.clone()),
|
||||||
ReErased => ReErased,
|
ReErased => ReErased,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1106,29 +968,17 @@ impl<I: Interner> Clone for RegionKind<I> {
|
||||||
impl<I: Interner> PartialEq for RegionKind<I> {
|
impl<I: Interner> PartialEq for RegionKind<I> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &RegionKind<I>) -> bool {
|
fn eq(&self, other: &RegionKind<I>) -> bool {
|
||||||
let __self_vi = regionkind_discriminant(self);
|
regionkind_discriminant(self) == regionkind_discriminant(other)
|
||||||
let __arg_1_vi = regionkind_discriminant(other);
|
&& match (self, other) {
|
||||||
if __self_vi == __arg_1_vi {
|
(ReEarlyBound(a_r), ReEarlyBound(b_r)) => a_r == b_r,
|
||||||
match (&*self, &*other) {
|
(ReLateBound(a_d, a_r), ReLateBound(b_d, b_r)) => a_d == b_d && a_r == b_r,
|
||||||
(&ReEarlyBound(ref __self_0), &ReEarlyBound(ref __arg_1_0)) => {
|
(ReFree(a_r), ReFree(b_r)) => a_r == b_r,
|
||||||
__self_0 == __arg_1_0
|
(ReStatic, ReStatic) => true,
|
||||||
}
|
(ReVar(a_r), ReVar(b_r)) => a_r == b_r,
|
||||||
(
|
(RePlaceholder(a_r), RePlaceholder(b_r)) => a_r == b_r,
|
||||||
&ReLateBound(ref __self_0, ref __self_1),
|
(ReErased, ReErased) => true,
|
||||||
&ReLateBound(ref __arg_1_0, ref __arg_1_1),
|
_ => true, // unreachable
|
||||||
) => __self_0 == __arg_1_0 && __self_1 == __arg_1_1,
|
|
||||||
(&ReFree(ref __self_0), &ReFree(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&ReStatic, &ReStatic) => true,
|
|
||||||
(&ReVar(ref __self_0), &ReVar(ref __arg_1_0)) => __self_0 == __arg_1_0,
|
|
||||||
(&RePlaceholder(ref __self_0), &RePlaceholder(ref __arg_1_0)) => {
|
|
||||||
__self_0 == __arg_1_0
|
|
||||||
}
|
|
||||||
(&ReErased, &ReErased) => true,
|
|
||||||
_ => true,
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,7 +989,7 @@ impl<I: Interner> Eq for RegionKind<I> {}
|
||||||
impl<I: Interner> PartialOrd for RegionKind<I> {
|
impl<I: Interner> PartialOrd for RegionKind<I> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &RegionKind<I>) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &RegionKind<I>) -> Option<Ordering> {
|
||||||
Some(Ord::cmp(self, other))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,66 +997,38 @@ impl<I: Interner> PartialOrd for RegionKind<I> {
|
||||||
impl<I: Interner> Ord for RegionKind<I> {
|
impl<I: Interner> Ord for RegionKind<I> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &RegionKind<I>) -> Ordering {
|
fn cmp(&self, other: &RegionKind<I>) -> Ordering {
|
||||||
let __self_vi = regionkind_discriminant(self);
|
regionkind_discriminant(self).cmp(®ionkind_discriminant(other)).then_with(|| {
|
||||||
let __arg_1_vi = regionkind_discriminant(other);
|
match (self, other) {
|
||||||
if __self_vi == __arg_1_vi {
|
(ReEarlyBound(a_r), ReEarlyBound(b_r)) => a_r.cmp(b_r),
|
||||||
match (&*self, &*other) {
|
(ReLateBound(a_d, a_r), ReLateBound(b_d, b_r)) => {
|
||||||
(&ReEarlyBound(ref __self_0), &ReEarlyBound(ref __arg_1_0)) => {
|
a_d.cmp(b_d).then_with(|| a_r.cmp(b_r))
|
||||||
Ord::cmp(__self_0, __arg_1_0)
|
|
||||||
}
|
}
|
||||||
(
|
(ReFree(a_r), ReFree(b_r)) => a_r.cmp(b_r),
|
||||||
&ReLateBound(ref __self_0, ref __self_1),
|
(ReStatic, ReStatic) => Ordering::Equal,
|
||||||
&ReLateBound(ref __arg_1_0, ref __arg_1_1),
|
(ReVar(a_r), ReVar(b_r)) => a_r.cmp(b_r),
|
||||||
) => match Ord::cmp(__self_0, __arg_1_0) {
|
(RePlaceholder(a_r), RePlaceholder(b_r)) => a_r.cmp(b_r),
|
||||||
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
|
(ReErased, ReErased) => Ordering::Equal,
|
||||||
cmp => cmp,
|
_ => Ordering::Equal, // unreachable
|
||||||
},
|
|
||||||
(&ReFree(ref __self_0), &ReFree(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
|
||||||
(&ReStatic, &ReStatic) => Ordering::Equal,
|
|
||||||
(&ReVar(ref __self_0), &ReVar(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
|
|
||||||
(&RePlaceholder(ref __self_0), &RePlaceholder(ref __arg_1_0)) => {
|
|
||||||
Ord::cmp(__self_0, __arg_1_0)
|
|
||||||
}
|
|
||||||
(&ReErased, &ReErased) => Ordering::Equal,
|
|
||||||
_ => Ordering::Equal,
|
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
Ord::cmp(&__self_vi, &__arg_1_vi)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is manually implemented because a derive would require `I: Hash`
|
// This is manually implemented because a derive would require `I: Hash`
|
||||||
impl<I: Interner> hash::Hash for RegionKind<I> {
|
impl<I: Interner> hash::Hash for RegionKind<I> {
|
||||||
fn hash<__H: hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<H: hash::Hasher>(&self, state: &mut H) -> () {
|
||||||
match (&*self,) {
|
regionkind_discriminant(self).hash(state);
|
||||||
(&ReEarlyBound(ref __self_0),) => {
|
match self {
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
ReEarlyBound(r) => r.hash(state),
|
||||||
hash::Hash::hash(__self_0, state)
|
ReLateBound(d, r) => {
|
||||||
}
|
d.hash(state);
|
||||||
(&ReLateBound(ref __self_0, ref __self_1),) => {
|
r.hash(state)
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state);
|
|
||||||
hash::Hash::hash(__self_1, state)
|
|
||||||
}
|
|
||||||
(&ReFree(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&ReStatic,) => {
|
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
|
||||||
}
|
|
||||||
(&ReVar(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&RePlaceholder(ref __self_0),) => {
|
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
|
||||||
hash::Hash::hash(__self_0, state)
|
|
||||||
}
|
|
||||||
(&ReErased,) => {
|
|
||||||
hash::Hash::hash(®ionkind_discriminant(self), state);
|
|
||||||
}
|
}
|
||||||
|
ReFree(r) => r.hash(state),
|
||||||
|
ReStatic => (),
|
||||||
|
ReVar(r) => r.hash(state),
|
||||||
|
RePlaceholder(r) => r.hash(state),
|
||||||
|
ReErased => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1215,21 +1037,21 @@ impl<I: Interner> hash::Hash for RegionKind<I> {
|
||||||
impl<I: Interner> fmt::Debug for RegionKind<I> {
|
impl<I: Interner> fmt::Debug for RegionKind<I> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ReEarlyBound(ref data) => write!(f, "ReEarlyBound({:?})", data),
|
ReEarlyBound(data) => write!(f, "ReEarlyBound({:?})", data),
|
||||||
|
|
||||||
ReLateBound(binder_id, ref bound_region) => {
|
ReLateBound(binder_id, bound_region) => {
|
||||||
write!(f, "ReLateBound({:?}, {:?})", binder_id, bound_region)
|
write!(f, "ReLateBound({:?}, {:?})", binder_id, bound_region)
|
||||||
}
|
}
|
||||||
|
|
||||||
ReFree(ref fr) => fr.fmt(f),
|
ReFree(fr) => fr.fmt(f),
|
||||||
|
|
||||||
ReStatic => write!(f, "ReStatic"),
|
ReStatic => f.write_str("ReStatic"),
|
||||||
|
|
||||||
ReVar(ref vid) => vid.fmt(f),
|
ReVar(vid) => vid.fmt(f),
|
||||||
|
|
||||||
RePlaceholder(placeholder) => write!(f, "RePlaceholder({:?})", placeholder),
|
RePlaceholder(placeholder) => write!(f, "RePlaceholder({:?})", placeholder),
|
||||||
|
|
||||||
ReErased => write!(f, "ReErased"),
|
ReErased => f.write_str("ReErased"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1317,18 +1139,18 @@ where
|
||||||
ReErased | ReStatic => {
|
ReErased | ReStatic => {
|
||||||
// No variant fields to hash for these ...
|
// No variant fields to hash for these ...
|
||||||
}
|
}
|
||||||
ReLateBound(db, br) => {
|
ReLateBound(d, r) => {
|
||||||
db.hash_stable(hcx, hasher);
|
d.hash_stable(hcx, hasher);
|
||||||
br.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
ReEarlyBound(eb) => {
|
ReEarlyBound(r) => {
|
||||||
eb.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
ReFree(ref free_region) => {
|
ReFree(r) => {
|
||||||
free_region.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
RePlaceholder(p) => {
|
RePlaceholder(r) => {
|
||||||
p.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
ReVar(_) => {
|
ReVar(_) => {
|
||||||
panic!("region variables should not be hashed: {self:?}")
|
panic!("region variables should not be hashed: {self:?}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue