Skip to content

Commit 7367eb5

Browse files
committed
---
yaml --- r: 157416 b: refs/heads/try c: ef765f5b1a4f34fcda478139257f9ccb8dfd48d9 h: refs/heads/master v: v3
1 parent 220b7d6 commit 7367eb5

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: 065caf34f5ff29e04605f95d9c5d511af219439a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: d44ea720fa9dfe062ef06d0eb49a58d4e7e92344
5-
refs/heads/try: 10925635cb035e639886154c95187a5df39207cf
5+
refs/heads/try: ef765f5b1a4f34fcda478139257f9ccb8dfd48d9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 6601b0501e31d08d3892a2d5a7d8a57ab120bf75

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
@@ -73,7 +73,7 @@ type Hint = attr::ReprAttr;
7373

7474

7575
/// Representations.
76-
#[deriving(Eq, PartialEq, Show)]
76+
#[deriving(Eq, Show)]
7777
pub enum Repr<'tcx> {
7878
/// C-like enums; basically an int.
7979
CEnum(IntType, Disr, Disr), // discriminant range (signedness based on the IntType)
@@ -125,6 +125,34 @@ pub enum Repr<'tcx> {
125125
}
126126
}
127127

128+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
129+
impl<'tcx> PartialEq for Repr<'tcx> {
130+
fn eq(&self, other: &Repr<'tcx>) -> bool {
131+
match (self, other) {
132+
(&CEnum(a_ty, a_start, a_end), &CEnum(b_ty, b_start, b_end)) => {
133+
a_ty == b_ty && a_start == b_start && a_end == b_end
134+
}
135+
(&Univariant(ref a_struct, a_dtor), &Univariant(ref b_struct, b_dtor)) => {
136+
a_struct == b_struct && a_dtor == b_dtor
137+
}
138+
(&General(a_discr, ref a_tys, a_dtor), &General(b_discr, ref b_tys, b_dtor)) => {
139+
a_discr == b_discr && a_tys == b_tys && a_dtor == b_dtor
140+
}
141+
(&RawNullablePointer { nndiscr: a_discr, nnty: a_ty, nullfields: ref a_fields},
142+
&RawNullablePointer { nndiscr: b_discr, nnty: b_ty, nullfields: ref b_fields}) => {
143+
a_discr == b_discr && a_ty == b_ty && a_fields == b_fields
144+
}
145+
(&StructWrappedNullablePointer { nonnull: ref a_struct, nndiscr: a_discr,
146+
ptrfield: a_ptr, nullfields: ref a_fields},
147+
&StructWrappedNullablePointer { nonnull: ref b_struct, nndiscr: b_discr,
148+
ptrfield: b_ptr, nullfields: ref b_fields}) => {
149+
a_struct == b_struct && a_discr == b_discr && a_ptr == b_ptr && a_fields == b_fields
150+
}
151+
_ => false
152+
}
153+
}
154+
}
155+
128156
/// For structs, and struct-like parts of anything fancier.
129157
#[deriving(Eq, PartialEq, Show)]
130158
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
@@ -1822,7 +1822,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18221822
let fcx = new_fn_ctxt(ccx,
18231823
llfndecl,
18241824
fn_ast_id,
1825-
closure_env.kind != closure::NotClosure,
1825+
closure_env.is_closure(),
18261826
output_type,
18271827
param_substs,
18281828
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,
@@ -607,7 +630,7 @@ impl<'tcx, S: Writer> Hash<S> for TyS<'tcx> {
607630
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
608631

609632
/// An entry in the type interner.
610-
struct InternedTy<'tcx> {
633+
pub struct InternedTy<'tcx> {
611634
ty: Ty<'tcx>
612635
}
613636

@@ -670,12 +693,23 @@ pub struct ClosureTy<'tcx> {
670693
pub abi: abi::Abi,
671694
}
672695

673-
#[deriving(Clone, PartialEq, Eq, Hash)]
696+
#[deriving(Clone, Eq, Hash)]
674697
pub enum FnOutput<'tcx> {
675698
FnConverging(Ty<'tcx>),
676699
FnDiverging
677700
}
678701

702+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
703+
impl<'tcx> PartialEq for FnOutput<'tcx> {
704+
fn eq(&self, other: &FnOutput<'tcx>) -> bool {
705+
match (*self, *other) {
706+
(FnConverging(a), FnConverging(b)) => a == b,
707+
(FnDiverging, FnDiverging) => true,
708+
_ => false
709+
}
710+
}
711+
}
712+
679713
impl<'tcx> FnOutput<'tcx> {
680714
pub fn unwrap(self) -> Ty<'tcx> {
681715
match self {
@@ -697,14 +731,25 @@ impl<'tcx> FnOutput<'tcx> {
697731
* - `output` is the return type.
698732
* - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
699733
*/
700-
#[deriving(Clone, PartialEq, Eq, Hash)]
734+
#[deriving(Clone, Eq, Hash)]
701735
pub struct FnSig<'tcx> {
702736
pub binder_id: ast::NodeId,
703737
pub inputs: Vec<Ty<'tcx>>,
704738
pub output: FnOutput<'tcx>,
705739
pub variadic: bool
706740
}
707741

742+
// FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
743+
impl<'tcx> PartialEq for FnSig<'tcx> {
744+
fn eq(&self, other: &FnSig<'tcx>) -> bool {
745+
let (a, b) = (self, other);
746+
a.binder_id == b.binder_id &&
747+
a.inputs == b.inputs &&
748+
a.output == b.output &&
749+
a.variadic == b.variadic
750+
}
751+
}
752+
708753
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
709754
pub struct ParamTy {
710755
pub space: subst::ParamSpace,
@@ -943,7 +988,7 @@ mod primitives {
943988

944989
// NB: If you change this, you'll probably want to change the corresponding
945990
// AST structure in libsyntax/ast.rs as well.
946-
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
991+
#[deriving(Clone, Eq, Hash, Show)]
947992
pub enum sty<'tcx> {
948993
ty_nil,
949994
ty_bool,
@@ -984,6 +1029,46 @@ pub enum sty<'tcx> {
9841029
// on non-useful type error messages)
9851030
}
9861031

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

0 commit comments

Comments
 (0)