]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #13013 : huonw/rust/tytrait, r=cmr
authorbors <bors@rust-lang.org>
Thu, 20 Mar 2014 03:21:48 +0000 (20:21 -0700)
committerbors <bors@rust-lang.org>
Thu, 20 Mar 2014 03:21:48 +0000 (20:21 -0700)
These variants occur rarely but inflate the whole enum for the other variants, leaving a lot of wasted space. In total this reduces `ty::sty` from 160 bytes to 96 (on a 64-bit platform).

After this, `ty_struct` and `ty_enum` are the largest variants, with the 80-byte `substs` being the major contributor.

20 files changed:
src/librustc/metadata/tyencode.rs
src/librustc/middle/kind.rs
src/librustc/middle/lint.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/reflect.rs
src/librustc/middle/ty.rs
src/librustc/middle/ty_fold.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/coherence.rs
src/librustc/middle/typeck/infer/coercion.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/variance.rs
src/librustc/util/ppaux.rs

index e78fe8e72a8d12f418ae0b8701373a462b3a4dc8..0934b6407fb744ea51f95232a5a0a2f7a2f972d9 100644 (file)
@@ -280,11 +280,11 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
             enc_substs(w, cx, substs);
             mywrite!(w, "]");
         }
-        ty::ty_trait(def, ref substs, store, mt, bounds) => {
-            mywrite!(w, "x[{}|", (cx.ds)(def));
+        ty::ty_trait(~ty::TyTrait { def_id, ref substs, store, mutability, bounds }) => {
+            mywrite!(w, "x[{}|", (cx.ds)(def_id));
             enc_substs(w, cx, substs);
             enc_trait_store(w, cx, store);
-            enc_mutability(w, mt);
+            enc_mutability(w, mutability);
             let bounds = ty::ParamBounds {builtin_bounds: bounds,
                                           trait_bounds: Vec::new()};
             enc_bounds(w, cx, &bounds);
@@ -315,7 +315,7 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
         ty::ty_unboxed_vec(mt) => { mywrite!(w, "U"); enc_mt(w, cx, mt); }
         ty::ty_closure(ref f) => {
             mywrite!(w, "f");
-            enc_closure_ty(w, cx, f);
+            enc_closure_ty(w, cx, *f);
         }
         ty::ty_bare_fn(ref f) => {
             mywrite!(w, "F");
index cc1fdc7699169fd20ebd7a49144bf72363755ec1..0f7106c389813ad7c0b76e49ab976e10379e162b 100644 (file)
@@ -208,21 +208,21 @@ fn check_for_bare(cx: &Context, fv: @freevar_entry) {
 
     let fty = ty::node_id_to_type(cx.tcx, id);
     match ty::get(fty).sty {
-        ty::ty_closure(ty::ClosureTy {
+        ty::ty_closure(~ty::ClosureTy {
             sigil: OwnedSigil,
             bounds: bounds,
             ..
         }) => {
             b(|cx, fv| check_for_uniq(cx, fv, bounds))
         }
-        ty::ty_closure(ty::ClosureTy {
+        ty::ty_closure(~ty::ClosureTy {
             sigil: ManagedSigil,
             ..
         }) => {
             // can't happen
             fail!("internal error: saw closure with managed sigil (@fn)");
         }
-        ty::ty_closure(ty::ClosureTy {
+        ty::ty_closure(~ty::ClosureTy {
             sigil: BorrowedSigil,
             bounds: bounds,
             region: region,
@@ -358,7 +358,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
 fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span: Span) {
     check_cast_for_escaping_regions(cx, source_ty, target_ty, span);
     match ty::get(target_ty).sty {
-        ty::ty_trait(_, _, _, _, bounds) => {
+        ty::ty_trait(~ty::TyTrait { bounds, .. }) => {
             check_trait_cast_bounds(cx, span, source_ty, bounds);
         }
         _ => {}
index 6ea26a9c5aab3ca7ab1320dc64de0b1d22a4783c..907d5fa621ee619d08ca0e22c84f8da6041e6f62 100644 (file)
@@ -911,7 +911,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
                 }
                 ty::ty_uniq(_) | ty::ty_str(ty::vstore_uniq) |
                 ty::ty_vec(_, ty::vstore_uniq) |
-                ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => {
+                ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) => {
                     n_uniq += 1;
                 }
                 ty::ty_closure(ref c) if c.sigil == ast::OwnedSigil => {
index be0aef64351ecba064d4588f4ba9c00ab7dc59b0..7c95815af54e50f9fb7051b1c5f5b9494ff5749b 100644 (file)
@@ -170,10 +170,10 @@ pub enum deref_kind {
 pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
     match ty::get(t).sty {
         ty::ty_uniq(_) |
-        ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
+        ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) |
         ty::ty_vec(_, ty::vstore_uniq) |
         ty::ty_str(ty::vstore_uniq) |
-        ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
+        ty::ty_closure(~ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
             Some(deref_ptr(OwnedPtr))
         }
 
@@ -183,13 +183,13 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
             Some(deref_ptr(BorrowedPtr(kind, r)))
         }
 
-        ty::ty_trait(_, _, ty::RegionTraitStore(r), m, _) => {
+        ty::ty_trait(~ty::TyTrait { store: ty::RegionTraitStore(r), mutability: m, .. }) => {
             let kind = ty::BorrowKind::from_mutbl(m);
             Some(deref_ptr(BorrowedPtr(kind, r)))
         }
 
         ty::ty_str(ty::vstore_slice(r)) |
-        ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil,
+        ty::ty_closure(~ty::ClosureTy {sigil: ast::BorrowedSigil,
                                       region: r, ..}) => {
             Some(deref_ptr(BorrowedPtr(ty::ImmBorrow, r)))
         }
index bcf0b5d5f64bdeed095b67c75454c194613ecdc6..7cdb4b07d03a823e825798d4acb1130fa98d5d06 100644 (file)
@@ -269,7 +269,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
             // noalias because the actual object pointer is nested.
             ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
             ty::ty_vec(_, ty::vstore_uniq) | ty::ty_str(ty::vstore_uniq) |
-            ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
+            ty::ty_closure(~ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
                 unsafe {
                     llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
                 }
index b044ee15b3b133b3de0db8b021b00b89a5444436..f87ce57089a41df0bc9935b0f21635226feb1305 100644 (file)
@@ -2126,7 +2126,9 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
         ty::ty_closure(ref closurety) => {
             subroutine_type_metadata(cx, &closurety.sig, usage_site_span)
         },
-        ty::ty_trait(def_id, ref substs, trait_store, mutability, ref bounds) => {
+        ty::ty_trait(~ty::TyTrait { def_id, ref substs,
+                                store: trait_store, mutability,
+                                ref bounds }) => {
             trait_metadata(cx, def_id, t, substs, trait_store, mutability, bounds)
         },
         ty::ty_struct(def_id, ref substs) => {
index 3a1572559dd00664c26f14041976e4d6a789bc18..836433e1daeaf36167c3c342518c5ab51f0e1e7f 100644 (file)
@@ -310,7 +310,7 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
                 }
             }
         }
-        ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => {
+        ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) => {
             let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]);
             // Only drop the value when it is non-null
             with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| {
index 397361b83e06add12eae033f7f4df6314afe548b..707cb2c8806221c9a9ab3798ed9520b0882198bb 100644 (file)
@@ -351,7 +351,7 @@ pub fn visit_ty(&mut self, t: ty::t) {
             })
           }
 
-          ty::ty_trait(_, _, _, _, _) => {
+          ty::ty_trait(..) => {
               let extra = [
                   self.c_slice(token::intern_and_get_ident(ty_to_str(tcx, t)))
               ];
index ae940ebeef2eb14f9c0b1511769bc552d83a37ff..61371cec49ea590321dd5dc92912b12cc95cbbb2 100644 (file)
@@ -746,8 +746,8 @@ pub enum sty {
     ty_ptr(mt),
     ty_rptr(Region, mt),
     ty_bare_fn(BareFnTy),
-    ty_closure(ClosureTy),
-    ty_trait(DefId, substs, TraitStore, ast::Mutability, BuiltinBounds),
+    ty_closure(~ClosureTy),
+    ty_trait(~TyTrait),
     ty_struct(DefId, substs),
     ty_tup(Vec<t>),
 
@@ -764,6 +764,15 @@ pub enum sty {
     ty_unboxed_vec(mt),
 }
 
+#[deriving(Clone, Eq, Hash)]
+pub struct TyTrait {
+    def_id: DefId,
+    substs: substs,
+    store: TraitStore,
+    mutability: ast::Mutability,
+    bounds: BuiltinBounds
+}
+
 #[deriving(Eq, Hash)]
 pub struct TraitRef {
     def_id: DefId,
@@ -1205,10 +1214,10 @@ fn sflags(substs: &substs) -> uint {
       &ty_infer(_) => flags |= needs_infer as uint,
       &ty_self(_) => flags |= has_self as uint,
       &ty_enum(_, ref substs) | &ty_struct(_, ref substs) |
-      &ty_trait(_, ref substs, _, _, _) => {
+      &ty_trait(~ty::TyTrait { ref substs, .. }) => {
           flags |= sflags(substs);
           match st {
-              ty_trait(_, _, RegionTraitStore(r), _, _) => {
+              ty_trait(~ty::TyTrait { store: RegionTraitStore(r), .. }) => {
                     flags |= rflags(r);
                 }
               _ => {}
@@ -1398,7 +1407,7 @@ pub fn mk_mut_unboxed_vec(cx: &ctxt, ty: t) -> t {
 pub fn mk_tup(cx: &ctxt, ts: Vec<t>) -> t { mk_t(cx, ty_tup(ts)) }
 
 pub fn mk_closure(cx: &ctxt, fty: ClosureTy) -> t {
-    mk_t(cx, ty_closure(fty))
+    mk_t(cx, ty_closure(~fty))
 }
 
 pub fn mk_bare_fn(cx: &ctxt, fty: BareFnTy) -> t {
@@ -1432,7 +1441,14 @@ pub fn mk_trait(cx: &ctxt,
                 bounds: BuiltinBounds)
              -> t {
     // take a copy of substs so that we own the vectors inside
-    mk_t(cx, ty_trait(did, substs, store, mutability, bounds))
+    let inner = ~TyTrait {
+        def_id: did,
+        substs: substs,
+        store: store,
+        mutability: mutability,
+        bounds: bounds
+    };
+    mk_t(cx, ty_trait(inner))
 }
 
 pub fn mk_struct(cx: &ctxt, struct_id: ast::DefId, substs: substs) -> t {
@@ -1472,7 +1488,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
             maybe_walk_ty(tm.ty, f);
         }
         ty_enum(_, ref substs) | ty_struct(_, ref substs) |
-        ty_trait(_, ref substs, _, _, _) => {
+        ty_trait(~TyTrait { ref substs, .. }) => {
             for subty in (*substs).tps.iter() { maybe_walk_ty(*subty, |x| f(x)); }
         }
         ty_tup(ref ts) => { for tt in ts.iter() { maybe_walk_ty(*tt, |x| f(x)); } }
@@ -2133,7 +2149,7 @@ fn tc_ty(cx: &ctxt,
             }
 
             ty_closure(ref c) => {
-                closure_contents(cx, c)
+                closure_contents(cx, *c)
             }
 
             ty_box(typ) => {
@@ -2144,8 +2160,8 @@ fn tc_ty(cx: &ctxt,
                 tc_ty(cx, typ, cache).owned_pointer()
             }
 
-            ty_trait(_, _, store, mutbl, bounds) => {
-                object_contents(cx, store, mutbl, bounds)
+            ty_trait(~ty::TyTrait { store, mutability, bounds, .. }) => {
+                object_contents(cx, store, mutability, bounds)
             }
 
             ty_ptr(ref mt) => {
@@ -2437,7 +2453,7 @@ fn subtypes_require(cx: &ctxt, seen: &mut Vec<DefId>,
                 false           // unsafe ptrs can always be NULL
             }
 
-            ty_trait(_, _, _, _, _) => {
+            ty_trait(..) => {
                 false
             }
 
@@ -2854,7 +2870,7 @@ pub fn ty_region(tcx: &ctxt,
 pub fn replace_fn_sig(cx: &ctxt, fsty: &sty, new_sig: FnSig) -> t {
     match *fsty {
         ty_bare_fn(ref f) => mk_bare_fn(cx, BareFnTy {sig: new_sig, ..*f}),
-        ty_closure(ref f) => mk_closure(cx, ClosureTy {sig: new_sig, ..*f}),
+        ty_closure(ref f) => mk_closure(cx, ClosureTy {sig: new_sig, ..**f}),
         ref s => {
             cx.sess.bug(
                 format!("ty_fn_sig() called on non-fn type: {:?}", s));
@@ -2872,7 +2888,7 @@ pub fn replace_closure_return_type(tcx: &ctxt, fn_type: t, ret_type: t) -> t {
         ty::ty_closure(ref fty) => {
             ty::mk_closure(tcx, ClosureTy {
                 sig: FnSig {output: ret_type, ..fty.sig.clone()},
-                ..(*fty).clone()
+                ..(**fty).clone()
             })
         }
         _ => {
@@ -3124,7 +3140,7 @@ fn borrow_fn(cx: &ctxt, span: Span, r: Region, ty: ty::t) -> ty::t {
                 ty::mk_closure(cx, ClosureTy {
                     sigil: BorrowedSigil,
                     region: r,
-                    ..(*fty).clone()
+                    ..(**fty).clone()
                 })
             }
 
@@ -3140,9 +3156,9 @@ fn borrow_fn(cx: &ctxt, span: Span, r: Region, ty: ty::t) -> ty::t {
     fn borrow_obj(cx: &ctxt, span: Span, r: Region,
                   m: ast::Mutability, ty: ty::t) -> ty::t {
         match get(ty).sty {
-            ty_trait(trt_did, ref trt_substs, _, _, b) => {
-                ty::mk_trait(cx, trt_did, trt_substs.clone(),
-                             RegionTraitStore(r), m, b)
+            ty_trait(~ty::TyTrait {def_id, ref substs, bounds, .. }) => {
+                ty::mk_trait(cx, def_id, substs.clone(),
+                             RegionTraitStore(r), m, bounds)
             }
             ref s => {
                 cx.sess.span_bug(
@@ -3479,7 +3495,7 @@ pub fn ty_sort_str(cx: &ctxt, t: t) -> ~str {
         ty_rptr(_, _) => ~"&-ptr",
         ty_bare_fn(_) => ~"extern fn",
         ty_closure(_) => ~"fn",
-        ty_trait(id, _, _, _, _) => format!("trait {}", item_path_str(cx, id)),
+        ty_trait(ref inner) => format!("trait {}", item_path_str(cx, inner.def_id)),
         ty_struct(id, _) => format!("struct {}", item_path_str(cx, id)),
         ty_tup(_) => ~"tuple",
         ty_infer(TyVar(_)) => ~"inferred type",
@@ -3865,7 +3881,7 @@ pub fn try_add_builtin_trait(tcx: &ctxt,
 
 pub fn ty_to_def_id(ty: t) -> Option<ast::DefId> {
     match get(ty).sty {
-      ty_trait(id, _, _, _, _) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
+      ty_trait(~TyTrait { def_id: id, .. }) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
       _ => None
     }
 }
@@ -4951,7 +4967,7 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
                 hash!(c.bounds);
                 region(&mut state, c.region);
             }
-            ty_trait(d, _, store, m, bounds) => {
+            ty_trait(~ty::TyTrait { def_id: d, store, mutability: m, bounds, .. }) => {
                 byte!(17);
                 did(&mut state, d);
                 match store {
index 2456c6073177d89aafa962ef24ad29ed42112e29..f75d707b0f3b0f98a50c08df231ee014afc77fb4 100644 (file)
@@ -159,12 +159,14 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T,
         ty::ty_enum(tid, ref substs) => {
             ty::ty_enum(tid, this.fold_substs(substs))
         }
-        ty::ty_trait(did, ref substs, st, mutbl, bounds) => {
-            ty::ty_trait(did,
-                     this.fold_substs(substs),
-                     this.fold_trait_store(st),
-                     mutbl,
-                     bounds)
+        ty::ty_trait(~ty::TyTrait { def_id, ref substs, store, mutability, bounds }) => {
+            ty::ty_trait(~ty::TyTrait{
+                def_id: def_id,
+                substs: this.fold_substs(substs),
+                store: this.fold_trait_store(store),
+                mutability: mutability,
+                bounds: bounds
+            })
         }
         ty::ty_tup(ref ts) => {
             ty::ty_tup(fold_ty_vec(this, ts.as_slice()))
@@ -173,7 +175,7 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T,
             ty::ty_bare_fn(this.fold_bare_fn_ty(f))
         }
         ty::ty_closure(ref f) => {
-            ty::ty_closure(this.fold_closure_ty(f))
+            ty::ty_closure(~this.fold_closure_ty(*f))
         }
         ty::ty_rptr(r, ref tm) => {
             ty::ty_rptr(this.fold_region(r),
index 5d232b488a6a70f46ec15a8bbd1907ba37af8fba..06a2c0b17b513969e5db2607b2fe281fb3daa21c 100644 (file)
@@ -417,9 +417,9 @@ fn push_inherent_candidates(&mut self, self_ty: ty::t) {
         let span = self.self_expr.map_or(self.span, |e| e.span);
         check::autoderef(self.fcx, span, self_ty, None, PreferMutLvalue, |self_ty, _| {
             match get(self_ty).sty {
-                ty_trait(did, ref substs, _, _, _) => {
-                    self.push_inherent_candidates_from_object(did, substs);
-                    self.push_inherent_impl_candidates_for_type(did);
+                ty_trait(~TyTrait { def_id, ref substs, .. }) => {
+                    self.push_inherent_candidates_from_object(def_id, substs);
+                    self.push_inherent_impl_candidates_for_type(def_id);
                 }
                 ty_enum(did, _) | ty_struct(did, _) => {
                     if self.check_traits == CheckTraitsAndInherentMethods {
@@ -775,10 +775,12 @@ fn consider_reborrow(&self,
                      autoderefs: autoderefs,
                      autoref: Some(ty::AutoBorrowVec(region, self_mt.mutbl))})
             }
-            ty::ty_trait(did, ref substs, ty::RegionTraitStore(_), mutbl, bounds) => {
+            ty::ty_trait(~ty::TyTrait {
+                def_id, ref substs, store: ty::RegionTraitStore(_), mutability: mutbl, bounds
+            }) => {
                 let region =
                     self.infcx().next_region_var(infer::Autoref(self.span));
-                (ty::mk_trait(tcx, did, substs.clone(),
+                (ty::mk_trait(tcx, def_id, substs.clone(),
                               ty::RegionTraitStore(region),
                               mutbl, bounds),
                  ty::AutoDerefRef {
@@ -860,7 +862,7 @@ fn search_for_autosliced_method(&self,
                     })
             }
 
-            ty_trait(trt_did, trt_substs, _, _, b) => {
+            ty_trait(~ty::TyTrait { def_id: trt_did, substs: trt_substs, bounds: b, .. }) => {
                 // Coerce ~/@/&Trait instances to &Trait.
 
                 self.search_for_some_kind_of_autorefd_method(
@@ -1301,7 +1303,9 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                         rcvr_matches_ty(self.fcx, mt.ty, candidate)
                     }
 
-                    ty::ty_trait(self_did, _, RegionTraitStore(_), self_m, _) => {
+                    ty::ty_trait(~ty::TyTrait {
+                        def_id: self_did, store: RegionTraitStore(_), mutability: self_m, ..
+                    }) => {
                         mutability_matches(self_m, m) &&
                         rcvr_matches_object(self_did, candidate)
                     }
@@ -1317,7 +1321,9 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                         rcvr_matches_ty(self.fcx, typ, candidate)
                     }
 
-                    ty::ty_trait(self_did, _, UniqTraitStore, _, _) => {
+                    ty::ty_trait(~ty::TyTrait {
+                        def_id: self_did, store: UniqTraitStore, ..
+                    }) => {
                         rcvr_matches_object(self_did, candidate)
                     }
 
index 205c1c106dd165d6adf7c997d7ad4923447a90d2..8ed28711194ff82808e6bf29caa34c3c95e14123 100644 (file)
@@ -1860,7 +1860,7 @@ fn check_call(fcx: &FnCtxt,
 
         let fn_sig = match *fn_sty {
             ty::ty_bare_fn(ty::BareFnTy {sig: ref sig, ..}) |
-            ty::ty_closure(ty::ClosureTy {sig: ref sig, ..}) => sig,
+            ty::ty_closure(~ty::ClosureTy {sig: ref sig, ..}) => sig,
             _ => {
                 fcx.type_error_message(call_expr.span, |actual| {
                     format!("expected function but \
index 4610305a70b08f247d394b26776922892cb9bcb4..1533943a55c2190553429c9a10f01557e1171bc1 100644 (file)
@@ -542,7 +542,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
             // explaining how it goes about doing that.
             let target_ty = rcx.resolve_node_type(expr.id);
             match ty::get(target_ty).sty {
-                ty::ty_trait(_, _, ty::RegionTraitStore(trait_region), _, _) => {
+                ty::ty_trait(~ty::TyTrait { store: ty::RegionTraitStore(trait_region), .. }) => {
                     let source_ty = rcx.resolve_expr_type_adjusted(source);
                     constrain_regions_in_type(
                         rcx,
@@ -610,7 +610,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
     let tcx = rcx.fcx.tcx();
     let function_type = rcx.resolve_node_type(expr.id);
     match ty::get(function_type).sty {
-        ty::ty_closure(ty::ClosureTy {
+        ty::ty_closure(~ty::ClosureTy {
                 sigil: ast::BorrowedSigil, region: region, ..}) => {
             let freevars = freevars::get_freevars(tcx, expr.id);
             if freevars.is_empty() {
@@ -635,7 +635,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
     rcx.set_repeating_scope(repeating_scope);
 
     match ty::get(function_type).sty {
-        ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil, ..}) => {
+        ty::ty_closure(~ty::ClosureTy {sigil: ast::BorrowedSigil, ..}) => {
             let freevars = freevars::get_freevars(tcx, expr.id);
             propagate_upupvar_borrow_kind(rcx, expr, freevars);
         }
index 600f0d6e3f2fa0c646365fede07c29c93e7f7def..890ed033b381666e492750e220d7a557f7e7524c 100644 (file)
@@ -479,7 +479,7 @@ fn fixup_substs(vcx: &VtableContext,
                          ty::EmptyBuiltinBounds());
     fixup_ty(vcx, span, t, is_early).map(|t_f| {
         match ty::get(t_f).sty {
-          ty::ty_trait(_, ref substs_f, _, _, _) => (*substs_f).clone(),
+          ty::ty_trait(ref inner) => inner.substs.clone(),
           _ => fail!("t_f should be a trait")
         }
     })
@@ -537,8 +537,10 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) {
     let resolve_object_cast = |src: &ast::Expr, target_ty: ty::t| {
       match ty::get(target_ty).sty {
           // Bounds of type's contents are not checked here, but in kind.rs.
-          ty::ty_trait(target_def_id, ref target_substs, store,
-                       target_mutbl, _bounds) => {
+          ty::ty_trait(~ty::TyTrait {
+              def_id: target_def_id, substs: ref target_substs, store: store,
+              mutability: target_mutbl, bounds: _bounds
+          }) => {
               fn mutability_allowed(a_mutbl: ast::Mutability,
                                     b_mutbl: ast::Mutability) -> bool {
                   a_mutbl == b_mutbl ||
index 894c70c7b61194f2592a3cd1f55d5b63d7fe3ec8..ac77ac20a7a73a0a4454c4793aef46bf70fc6e22 100644 (file)
@@ -106,7 +106,7 @@ fn type_is_defined_in_local_crate(original_type: t) -> bool {
     ty::walk_ty(original_type, |t| {
         match get(t).sty {
             ty_enum(def_id, _) |
-            ty_trait(def_id, _, _, _, _) |
+            ty_trait(~ty::TyTrait { def_id, .. }) |
             ty_struct(def_id, _) => {
                 if def_id.krate == ast::LOCAL_CRATE {
                     found_nominal = true;
@@ -132,7 +132,7 @@ fn get_base_type_def_id(inference_context: &InferCtxt,
             match get(base_type).sty {
                 ty_enum(def_id, _) |
                 ty_struct(def_id, _) |
-                ty_trait(def_id, _, _, _, _) => {
+                ty_trait(~ty::TyTrait { def_id, .. }) => {
                     return Some(def_id);
                 }
                 _ => {
index d8166108947fd75eb185577e2138a5eef57cb707..5dc55ab4b5c07056084b91e5b0cbb60c73d48fa4 100644 (file)
@@ -119,7 +119,7 @@ pub fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
                 });
             }
 
-            ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil, ..}) => {
+            ty::ty_closure(~ty::ClosureTy {sigil: ast::BorrowedSigil, ..}) => {
                 return self.unpack_actual_value(a, |sty_a| {
                     self.coerce_borrowed_fn(a, sty_a, b)
                 });
@@ -131,7 +131,9 @@ pub fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
                 });
             }
 
-            ty::ty_trait(def_id, ref substs, ty::UniqTraitStore, m, bounds) => {
+            ty::ty_trait(~ty::TyTrait {
+                def_id, ref substs, store: ty::UniqTraitStore, mutability: m, bounds
+            }) => {
                 let result = self.unpack_actual_value(a, |sty_a| {
                     match *sty_a {
                         ty::ty_uniq(..) => {
@@ -148,7 +150,9 @@ pub fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
                 }
             }
 
-            ty::ty_trait(def_id, ref substs, ty::RegionTraitStore(region), m, bounds) => {
+            ty::ty_trait(~ty::TyTrait {
+                def_id, ref substs, store: ty::RegionTraitStore(region), mutability: m, bounds
+            }) => {
                 let result = self.unpack_actual_value(a, |sty_a| {
                     match *sty_a {
                         ty::ty_rptr(..) => {
@@ -313,9 +317,9 @@ fn coerce_borrowed_object(&self,
         let r_a = self.get_ref().infcx.next_region_var(Coercion(self.get_ref().trace));
 
         let a_borrowed = match *sty_a {
-            ty::ty_trait(did, ref substs, _, _, b) => {
-                ty::mk_trait(tcx, did, substs.clone(),
-                             ty::RegionTraitStore(r_a), b_mutbl, b)
+            ty::ty_trait(~ty::TyTrait { def_id, ref substs, bounds, .. }) => {
+                ty::mk_trait(tcx, def_id, substs.clone(),
+                             ty::RegionTraitStore(r_a), b_mutbl, bounds)
             }
             _ => {
                 return self.subtype(a, b);
@@ -357,7 +361,7 @@ pub fn coerce_borrowed_fn(&self,
             ty::ClosureTy {
                 sigil: ast::BorrowedSigil,
                 region: r_borrow,
-                ..fn_ty
+                .. *fn_ty
             });
 
         if_ok!(self.subtype(a_borrowed, b));
@@ -393,7 +397,7 @@ fn coerce_from_bare_fn(&self, a: ty::t, fn_ty_a: &ty::BareFnTy, b: ty::t)
             let a_closure = ty::mk_closure(self.get_ref().infcx.tcx,
                                            ty::ClosureTy {
                                                 sig: fn_ty_a.sig.clone(),
-                                                ..fn_ty_b
+                                                .. *fn_ty_b
                                            });
             if_ok!(self.subtype(a_closure, b));
             Ok(Some(adj))
index f6894f44099889c66865679b5d9c3d669e0f8403..b05e168e9434c8feee4fb6e389e366c97b40c23d 100644 (file)
@@ -500,18 +500,18 @@ pub fn super_tys<C:Combine>(this: &C, a: ty::t, b: ty::t) -> cres<ty::t> {
           Ok(ty::mk_enum(tcx, a_id, substs))
       }
 
-      (&ty::ty_trait(a_id, ref a_substs, a_store, a_mutbl, a_bounds),
-       &ty::ty_trait(b_id, ref b_substs, b_store, b_mutbl, b_bounds))
-      if a_id == b_id && a_mutbl == b_mutbl => {
+      (&ty::ty_trait(ref a_),
+       &ty::ty_trait(ref b_))
+      if a_.def_id == b_.def_id && a_.mutability == b_.mutability => {
           debug!("Trying to match traits {:?} and {:?}", a, b);
-          let substs = if_ok!(this.substs(a_id, a_substs, b_substs));
-          let s = if_ok!(this.trait_stores(ty::terr_trait, a_store, b_store));
-          let bounds = if_ok!(this.bounds(a_bounds, b_bounds));
+          let substs = if_ok!(this.substs(a_.def_id, &a_.substs, &b_.substs));
+          let s = if_ok!(this.trait_stores(ty::terr_trait, a_.store, b_.store));
+          let bounds = if_ok!(this.bounds(a_.bounds, b_.bounds));
           Ok(ty::mk_trait(tcx,
-                          a_id,
+                          a_.def_id,
                           substs.clone(),
                           s,
-                          a_mutbl,
+                          a_.mutability,
                           bounds))
       }
 
@@ -570,7 +570,7 @@ pub fn super_tys<C:Combine>(this: &C, a: ty::t, b: ty::t) -> cres<ty::t> {
       }
 
       (&ty::ty_closure(ref a_fty), &ty::ty_closure(ref b_fty)) => {
-        this.closure_tys(a_fty, b_fty).and_then(|fty| {
+        this.closure_tys(*a_fty, *b_fty).and_then(|fty| {
             Ok(ty::mk_closure(tcx, fty))
         })
       }
index 07948477800a18637bff9fb2f86bd8776e371716..fc1970b09d422cfd32746ef2fbe7f9ec348bc6c4 100644 (file)
@@ -719,7 +719,7 @@ pub fn resolve_type_vars_in_trait_ref_if_possible(&self,
                                   ty::EmptyBuiltinBounds());
         let dummy1 = self.resolve_type_vars_if_possible(dummy0);
         match ty::get(dummy1).sty {
-            ty::ty_trait(ref def_id, ref substs, _, _, _) => {
+            ty::ty_trait(~ty::TyTrait { ref def_id, ref substs, .. }) => {
                 ty::TraitRef {
                     def_id: *def_id,
                     substs: (*substs).clone(),
@@ -976,4 +976,3 @@ fn repr(&self, tcx: &ty::ctxt) -> ~str {
         }
     }
 }
-
index 468d97a83925f20d89dd2e71d951cfde21d46e2b..f9c336a499401b400cbdcf68e17a463951b9b7e1 100644 (file)
@@ -675,7 +675,7 @@ fn add_constraints_from_ty(&mut self,
                                                  substs, variance);
             }
 
-            ty::ty_trait(def_id, ref substs, _, _, _) => {
+            ty::ty_trait(~ty::TyTrait { def_id, ref substs, .. }) => {
                 let trait_def = ty::lookup_trait_def(self.tcx(), def_id);
                 self.add_constraints_from_substs(def_id, &trait_def.generics,
                                                  substs, variance);
@@ -705,7 +705,7 @@ fn add_constraints_from_ty(&mut self,
                 self.add_constraints_from_sig(sig, variance);
             }
 
-            ty::ty_closure(ty::ClosureTy { sig: ref sig, region, .. }) => {
+            ty::ty_closure(~ty::ClosureTy { sig: ref sig, region, .. }) => {
                 let contra = self.contravariant(variance);
                 self.add_constraints_from_region(region, contra);
                 self.add_constraints_from_sig(sig, variance);
index b3d3e59ea6b3f16afc8530ec9a202c50affad7bc..7c03c1dc45dfb95a4bd625dd6c851bdfa197569e 100644 (file)
@@ -453,7 +453,7 @@ fn push_sig_to_str(cx: &ctxt,
         ~"(" + strs.connect(",") + ")"
       }
       ty_closure(ref f) => {
-          closure_to_str(cx, f)
+          closure_to_str(cx, *f)
       }
       ty_bare_fn(ref f) => {
           bare_fn_to_str(cx, f.purity, f.abis, None, &f.sig)
@@ -484,7 +484,9 @@ fn push_sig_to_str(cx: &ctxt,
                       did,
                       false)
       }
-      ty_trait(did, ref substs, s, mutbl, ref bounds) => {
+      ty_trait(~ty::TyTrait {
+          def_id: did, ref substs, store: s, mutability: mutbl, ref bounds
+      }) => {
         let base = ty::item_path_str(cx, did);
         let ty = parameterized(cx, base, &substs.regions,
                                substs.tps.as_slice(), did, true);