Skip to content

Commit 75063f5

Browse files
committed
---
yaml --- r: 158639 b: refs/heads/try c: 9740643 h: refs/heads/master i: 158637: cc16146 158635: ef44a5d 158631: 694e995 158623: 62754c5 v: v3
1 parent efaaa89 commit 75063f5

File tree

6 files changed

+143
-11
lines changed

6 files changed

+143
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: a0a7ab461283322215f0343cd2b5e66fc19a7bd5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 1b2ad7831f1745bf4a4709a1fa1772afb47c933c
5-
refs/heads/try: 7d2da3a8dbe8284678607e0b07f4d94ab22a37c8
5+
refs/heads/try: 9740643070df37e61bdaa65a7ce8d661f480a911
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc/middle/mem_categorization.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub enum Note {
163163
// dereference, but its type is the type *before* the dereference
164164
// (`@T`). So use `cmt.ty` to find the type of the value in a consistent
165165
// fashion. For more details, see the method `cat_pattern`
166-
#[deriving(Clone, PartialEq, Show)]
166+
#[deriving(Clone, Show)]
167167
pub struct cmt_<'tcx> {
168168
pub id: ast::NodeId, // id of expr/pat producing this value
169169
pub span: Span, // span of same expr/pat
@@ -173,6 +173,19 @@ pub struct cmt_<'tcx> {
173173
pub note: Note, // Note about the provenance of this cmt
174174
}
175175

176+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
177+
impl<'tcx> PartialEq for cmt_<'tcx> {
178+
fn eq(&self, other: &cmt_<'tcx>) -> bool {
179+
let (a, b) = (self, other);
180+
a.id == b.id &&
181+
a.span == b.span &&
182+
a.cat == b.cat &&
183+
a.mutbl == b.mutbl &&
184+
a.ty == b.ty &&
185+
a.note == b.note
186+
}
187+
}
188+
176189
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
177190

178191
// We pun on *T to mean both actual deref of a ptr as well

branches/try/src/librustc/middle/trans/adt.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type Hint = attr::ReprAttr;
7171

7272

7373
/// Representations.
74-
#[deriving(Eq, PartialEq, Show)]
74+
#[deriving(Eq, Show)]
7575
pub enum Repr<'tcx> {
7676
/// C-like enums; basically an int.
7777
CEnum(IntType, Disr, Disr), // discriminant range (signedness based on the IntType)
@@ -123,6 +123,34 @@ pub enum Repr<'tcx> {
123123
}
124124
}
125125

126+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
127+
impl<'tcx> PartialEq for Repr<'tcx> {
128+
fn eq(&self, other: &Repr<'tcx>) -> bool {
129+
match (self, other) {
130+
(&CEnum(a_ty, a_start, a_end), &CEnum(b_ty, b_start, b_end)) => {
131+
a_ty == b_ty && a_start == b_start && a_end == b_end
132+
}
133+
(&Univariant(ref a_struct, a_dtor), &Univariant(ref b_struct, b_dtor)) => {
134+
a_struct == b_struct && a_dtor == b_dtor
135+
}
136+
(&General(a_discr, ref a_tys, a_dtor), &General(b_discr, ref b_tys, b_dtor)) => {
137+
a_discr == b_discr && a_tys == b_tys && a_dtor == b_dtor
138+
}
139+
(&RawNullablePointer { nndiscr: a_discr, nnty: a_ty, nullfields: ref a_fields},
140+
&RawNullablePointer { nndiscr: b_discr, nnty: b_ty, nullfields: ref b_fields}) => {
141+
a_discr == b_discr && a_ty == b_ty && a_fields == b_fields
142+
}
143+
(&StructWrappedNullablePointer { nonnull: ref a_struct, nndiscr: a_discr,
144+
ptrfield: a_ptr, nullfields: ref a_fields},
145+
&StructWrappedNullablePointer { nonnull: ref b_struct, nndiscr: b_discr,
146+
ptrfield: b_ptr, nullfields: ref b_fields}) => {
147+
a_struct == b_struct && a_discr == b_discr && a_ptr == b_ptr && a_fields == b_fields
148+
}
149+
_ => false
150+
}
151+
}
152+
}
153+
126154
/// For structs, and struct-like parts of anything fancier.
127155
#[deriving(Eq, PartialEq, Show)]
128156
pub struct Struct<'tcx> {

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18231823
let fcx = new_fn_ctxt(ccx,
18241824
llfndecl,
18251825
fn_ast_id,
1826-
closure_env.kind != closure::NotClosure,
1826+
closure_env.is_closure(),
18271827
output_type,
18281828
param_substs,
18291829
Some(body.span),

branches/try/src/librustc/middle/trans/closure.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ fn fill_fn_pair(bcx: Block, pair: ValueRef, llfn: ValueRef, llenvptr: ValueRef)
344344
Store(bcx, llenvptr, GEPi(bcx, pair, [0u, abi::fn_field_box]));
345345
}
346346

347-
#[deriving(PartialEq)]
348347
pub enum ClosureKind<'tcx> {
349348
NotClosure,
350349
// See load_environment.
@@ -384,6 +383,13 @@ impl<'a, 'tcx> ClosureEnv<'a, 'tcx> {
384383
}
385384
}
386385
}
386+
387+
pub fn is_closure(&self) -> bool {
388+
match self.kind {
389+
NotClosure => false,
390+
BoxedClosure(..) | UnboxedClosure(..) => true
391+
}
392+
}
387393
}
388394

389395
pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,

branches/try/src/librustc/middle/ty.rs

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,19 @@ pub struct AssociatedType {
196196
pub container: ImplOrTraitItemContainer,
197197
}
198198

199-
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
199+
#[deriving(Clone, Eq, Hash, Show)]
200200
pub struct mt<'tcx> {
201201
pub ty: Ty<'tcx>,
202202
pub mutbl: ast::Mutability,
203203
}
204204

205+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
206+
impl<'tcx> PartialEq for mt<'tcx> {
207+
fn eq(&self, other: &mt<'tcx>) -> bool {
208+
self.ty == other.ty && self.mutbl == other.mutbl
209+
}
210+
}
211+
205212
#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
206213
pub enum TraitStore {
207214
/// Box<Trait>
@@ -254,7 +261,7 @@ pub enum AutoAdjustment<'tcx> {
254261
AdjustDerefRef(AutoDerefRef<'tcx>)
255262
}
256263

257-
#[deriving(Clone, PartialEq, Show)]
264+
#[deriving(Clone, Show)]
258265
pub enum UnsizeKind<'tcx> {
259266
// [T, ..n] -> [T], the uint field is n.
260267
UnsizeLength(uint),
@@ -264,6 +271,22 @@ pub enum UnsizeKind<'tcx> {
264271
UnsizeVtable(TyTrait<'tcx>, /* the self type of the trait */ Ty<'tcx>)
265272
}
266273

274+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
275+
impl<'tcx> PartialEq for UnsizeKind<'tcx> {
276+
fn eq(&self, other: &UnsizeKind<'tcx>) -> bool {
277+
match (self, other) {
278+
(&UnsizeLength(a), &UnsizeLength(b)) => a == b,
279+
(&UnsizeStruct(ref a_kind, a_idx), &UnsizeStruct(ref b_kind, b_idx)) => {
280+
a_kind == b_kind && a_idx == b_idx
281+
}
282+
(&UnsizeVtable(ref a_trait, a_self), &UnsizeVtable(ref b_trait, b_self)) => {
283+
a_trait == b_trait && a_self == b_self
284+
}
285+
_ => false
286+
}
287+
}
288+
}
289+
267290
#[deriving(Clone, Show)]
268291
pub struct AutoDerefRef<'tcx> {
269292
pub autoderefs: uint,
@@ -603,7 +626,7 @@ impl<'tcx, S: Writer> Hash<S> for TyS<'tcx> {
603626
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
604627

605628
/// An entry in the type interner.
606-
struct InternedTy<'tcx> {
629+
pub struct InternedTy<'tcx> {
607630
ty: Ty<'tcx>
608631
}
609632

@@ -666,12 +689,23 @@ pub struct ClosureTy<'tcx> {
666689
pub abi: abi::Abi,
667690
}
668691

669-
#[deriving(Clone, PartialEq, Eq, Hash)]
692+
#[deriving(Clone, Eq, Hash)]
670693
pub enum FnOutput<'tcx> {
671694
FnConverging(Ty<'tcx>),
672695
FnDiverging
673696
}
674697

698+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
699+
impl<'tcx> PartialEq for FnOutput<'tcx> {
700+
fn eq(&self, other: &FnOutput<'tcx>) -> bool {
701+
match (*self, *other) {
702+
(FnConverging(a), FnConverging(b)) => a == b,
703+
(FnDiverging, FnDiverging) => true,
704+
_ => false
705+
}
706+
}
707+
}
708+
675709
impl<'tcx> FnOutput<'tcx> {
676710
pub fn unwrap(self) -> Ty<'tcx> {
677711
match self {
@@ -693,14 +727,25 @@ impl<'tcx> FnOutput<'tcx> {
693727
* - `output` is the return type.
694728
* - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
695729
*/
696-
#[deriving(Clone, PartialEq, Eq, Hash)]
730+
#[deriving(Clone, Eq, Hash)]
697731
pub struct FnSig<'tcx> {
698732
pub binder_id: ast::NodeId,
699733
pub inputs: Vec<Ty<'tcx>>,
700734
pub output: FnOutput<'tcx>,
701735
pub variadic: bool
702736
}
703737

738+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
739+
impl<'tcx> PartialEq for FnSig<'tcx> {
740+
fn eq(&self, other: &FnSig<'tcx>) -> bool {
741+
let (a, b) = (self, other);
742+
a.binder_id == b.binder_id &&
743+
a.inputs == b.inputs &&
744+
a.output == b.output &&
745+
a.variadic == b.variadic
746+
}
747+
}
748+
704749
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
705750
pub struct ParamTy {
706751
pub space: subst::ParamSpace,
@@ -939,7 +984,7 @@ mod primitives {
939984

940985
// NB: If you change this, you'll probably want to change the corresponding
941986
// AST structure in libsyntax/ast.rs as well.
942-
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
987+
#[deriving(Clone, Eq, Hash, Show)]
943988
pub enum sty<'tcx> {
944989
ty_nil,
945990
ty_bool,
@@ -980,6 +1025,46 @@ pub enum sty<'tcx> {
9801025
// on non-useful type error messages)
9811026
}
9821027

1028+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
1029+
impl<'tcx> PartialEq for sty<'tcx> {
1030+
fn eq(&self, other: &sty<'tcx>) -> bool {
1031+
match (self, other) {
1032+
(&ty_nil, &ty_nil) |
1033+
(&ty_bool, &ty_bool) |
1034+
(&ty_char, &ty_char) |
1035+
(&ty_str, &ty_str) |
1036+
(&ty_err, &ty_err) => true,
1037+
(&ty_int(a), &ty_int(b)) => a == b,
1038+
(&ty_uint(a), &ty_uint(b)) => a == b,
1039+
(&ty_float(a), &ty_float(b)) => a == b,
1040+
(&ty_uniq(a), &ty_uniq(b)) |
1041+
(&ty_open(a), &ty_open(b)) => a == b,
1042+
(&ty_enum(a_def, ref a_substs), &ty_enum(b_def, ref b_substs)) |
1043+
(&ty_struct(a_def, ref a_substs), &ty_struct(b_def, ref b_substs)) => {
1044+
a_def == b_def && a_substs == b_substs
1045+
}
1046+
(&ty_vec(a_ty, a_len), &ty_vec(b_ty, b_len)) => {
1047+
a_ty == b_ty && a_len == b_len
1048+
}
1049+
(&ty_ptr(a), &ty_ptr(b)) => a == b,
1050+
(&ty_rptr(a_lt, a_ty), &ty_rptr(b_lt, b_ty)) => {
1051+
a_lt == b_lt && a_ty == b_ty
1052+
}
1053+
(&ty_bare_fn(ref a), &ty_bare_fn(ref b)) => a == b,
1054+
(&ty_closure(ref a), &ty_closure(ref b)) => a == b,
1055+
(&ty_trait(ref a), &ty_trait(ref b)) => a == b,
1056+
(&ty_unboxed_closure(a_def, a_lt, ref a_substs),
1057+
&ty_unboxed_closure(b_def, b_lt, ref b_substs)) => {
1058+
a_def == b_def && a_lt == b_lt && a_substs == b_substs
1059+
}
1060+
(&ty_tup(ref a), &ty_tup(ref b)) => a == b,
1061+
(&ty_param(a), &ty_param(b)) => a == b,
1062+
(&ty_infer(a), &ty_infer(b)) => a == b,
1063+
_ => false
1064+
}
1065+
}
1066+
}
1067+
9831068
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
9841069
pub struct TyTrait<'tcx> {
9851070
pub def_id: DefId,

0 commit comments

Comments
 (0)