@@ -746,8 +746,8 @@ pub enum sty {
746746 ty_ptr( mt ) ,
747747 ty_rptr( Region , mt ) ,
748748 ty_bare_fn( BareFnTy ) ,
749- ty_closure( ClosureTy ) ,
750- ty_trait( DefId , substs , TraitStore , ast :: Mutability , BuiltinBounds ) ,
749+ ty_closure( ~ ClosureTy ) ,
750+ ty_trait( ~ TyTrait ) ,
751751 ty_struct( DefId , substs ) ,
752752 ty_tup( Vec < t > ) ,
753753
@@ -764,6 +764,15 @@ pub enum sty {
764764 ty_unboxed_vec( mt ) ,
765765}
766766
767+ #[ deriving( Clone , Eq , Hash ) ]
768+ pub struct TyTrait {
769+ def_id : DefId ,
770+ substs : substs ,
771+ store : TraitStore ,
772+ mutability : ast:: Mutability ,
773+ bounds : BuiltinBounds
774+ }
775+
767776#[ deriving( Eq , Hash ) ]
768777pub struct TraitRef {
769778 def_id : DefId ,
@@ -1205,10 +1214,10 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
12051214 & ty_infer( _) => flags |= needs_infer as uint ,
12061215 & ty_self( _) => flags |= has_self as uint ,
12071216 & ty_enum( _, ref substs) | & ty_struct( _, ref substs) |
1208- & ty_trait( _ , ref substs, _ , _ , _ ) => {
1217+ & ty_trait( ~ty :: TyTrait { ref substs, .. } ) => {
12091218 flags |= sflags ( substs) ;
12101219 match st {
1211- ty_trait( _ , _ , RegionTraitStore ( r) , _ , _ ) => {
1220+ ty_trait( ~ty :: TyTrait { store : RegionTraitStore ( r) , .. } ) => {
12121221 flags |= rflags ( r) ;
12131222 }
12141223 _ => { }
@@ -1398,7 +1407,7 @@ pub fn mk_mut_unboxed_vec(cx: &ctxt, ty: t) -> t {
13981407pub fn mk_tup ( cx : & ctxt , ts : Vec < t > ) -> t { mk_t ( cx, ty_tup ( ts) ) }
13991408
14001409pub fn mk_closure ( cx : & ctxt , fty : ClosureTy ) -> t {
1401- mk_t ( cx, ty_closure ( fty) )
1410+ mk_t ( cx, ty_closure ( ~ fty) )
14021411}
14031412
14041413pub fn mk_bare_fn ( cx : & ctxt , fty : BareFnTy ) -> t {
@@ -1432,7 +1441,14 @@ pub fn mk_trait(cx: &ctxt,
14321441 bounds : BuiltinBounds )
14331442 -> t {
14341443 // take a copy of substs so that we own the vectors inside
1435- mk_t ( cx, ty_trait ( did, substs, store, mutability, bounds) )
1444+ let inner = ~TyTrait {
1445+ def_id : did,
1446+ substs : substs,
1447+ store : store,
1448+ mutability : mutability,
1449+ bounds : bounds
1450+ } ;
1451+ mk_t ( cx, ty_trait ( inner) )
14361452}
14371453
14381454pub 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) {
14721488 maybe_walk_ty ( tm. ty , f) ;
14731489 }
14741490 ty_enum( _, ref substs) | ty_struct( _, ref substs) |
1475- ty_trait( _ , ref substs, _ , _ , _ ) => {
1491+ ty_trait( ~ TyTrait { ref substs, .. } ) => {
14761492 for subty in ( * substs) . tps . iter ( ) { maybe_walk_ty ( * subty, |x| f ( x) ) ; }
14771493 }
14781494 ty_tup( ref ts) => { for tt in ts. iter ( ) { maybe_walk_ty ( * tt, |x| f ( x) ) ; } }
@@ -2133,7 +2149,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
21332149 }
21342150
21352151 ty_closure( ref c) => {
2136- closure_contents ( cx, c)
2152+ closure_contents ( cx, * c)
21372153 }
21382154
21392155 ty_box( typ) => {
@@ -2144,8 +2160,8 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
21442160 tc_ty ( cx, typ, cache) . owned_pointer ( )
21452161 }
21462162
2147- ty_trait( _ , _ , store, mutbl , bounds) => {
2148- object_contents ( cx, store, mutbl , bounds)
2163+ ty_trait( ~ty :: TyTrait { store, mutability , bounds, .. } ) => {
2164+ object_contents ( cx, store, mutability , bounds)
21492165 }
21502166
21512167 ty_ptr( ref mt) => {
@@ -2437,7 +2453,7 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool {
24372453 false // unsafe ptrs can always be NULL
24382454 }
24392455
2440- ty_trait( _ , _ , _ , _ , _ ) => {
2456+ ty_trait( .. ) => {
24412457 false
24422458 }
24432459
@@ -2854,7 +2870,7 @@ pub fn ty_region(tcx: &ctxt,
28542870pub fn replace_fn_sig ( cx : & ctxt , fsty : & sty , new_sig : FnSig ) -> t {
28552871 match * fsty {
28562872 ty_bare_fn( ref f) => mk_bare_fn ( cx, BareFnTy { sig : new_sig, ..* f} ) ,
2857- ty_closure( ref f) => mk_closure ( cx, ClosureTy { sig : new_sig, ..* f} ) ,
2873+ ty_closure( ref f) => mk_closure ( cx, ClosureTy { sig : new_sig, ..* * f} ) ,
28582874 ref s => {
28592875 cx. sess . bug (
28602876 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 {
28722888 ty:: ty_closure( ref fty) => {
28732889 ty:: mk_closure ( tcx, ClosureTy {
28742890 sig : FnSig { output : ret_type, ..fty. sig . clone ( ) } ,
2875- ..( * fty) . clone ( )
2891+ ..( * * fty) . clone ( )
28762892 } )
28772893 }
28782894 _ => {
@@ -3124,7 +3140,7 @@ pub fn adjust_ty(cx: &ctxt,
31243140 ty:: mk_closure ( cx, ClosureTy {
31253141 sigil : BorrowedSigil ,
31263142 region : r,
3127- ..( * fty) . clone ( )
3143+ ..( * * fty) . clone ( )
31283144 } )
31293145 }
31303146
@@ -3140,9 +3156,9 @@ pub fn adjust_ty(cx: &ctxt,
31403156 fn borrow_obj ( cx : & ctxt , span : Span , r : Region ,
31413157 m : ast:: Mutability , ty : ty:: t ) -> ty:: t {
31423158 match get ( ty) . sty {
3143- ty_trait( trt_did , ref trt_substs , _ , _ , b ) => {
3144- ty:: mk_trait ( cx, trt_did , trt_substs . clone ( ) ,
3145- RegionTraitStore ( r) , m, b )
3159+ ty_trait( ~ty :: TyTrait { def_id , ref substs , bounds , .. } ) => {
3160+ ty:: mk_trait ( cx, def_id , substs . clone ( ) ,
3161+ RegionTraitStore ( r) , m, bounds )
31463162 }
31473163 ref s => {
31483164 cx. sess . span_bug (
@@ -3479,7 +3495,7 @@ pub fn ty_sort_str(cx: &ctxt, t: t) -> ~str {
34793495 ty_rptr( _, _) => ~"& -ptr",
34803496 ty_bare_fn( _) => ~"extern fn ",
34813497 ty_closure ( _) => ~"fn ",
3482- ty_trait( id , _ , _ , _ , _ ) => format ! ( "trait {}" , item_path_str( cx, id ) ) ,
3498+ ty_trait( ref inner ) => format ! ( "trait {}" , item_path_str( cx, inner . def_id ) ) ,
34833499 ty_struct( id, _) => format ! ( "struct {}" , item_path_str( cx, id) ) ,
34843500 ty_tup( _) => ~"tuple",
34853501 ty_infer( TyVar ( _) ) => ~"inferred type",
@@ -3865,7 +3881,7 @@ pub fn try_add_builtin_trait(tcx: &ctxt,
38653881
38663882pub fn ty_to_def_id ( ty : t ) -> Option < ast:: DefId > {
38673883 match get ( ty) . sty {
3868- ty_trait( id , _ , _ , _ , _ ) | ty_struct( id, _) | ty_enum( id, _) => Some ( id) ,
3884+ ty_trait( ~ TyTrait { def_id : id , .. } ) | ty_struct( id, _) | ty_enum( id, _) => Some ( id) ,
38693885 _ => None
38703886 }
38713887}
@@ -4951,7 +4967,7 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
49514967 hash ! ( c. bounds) ;
49524968 region ( & mut state, c. region ) ;
49534969 }
4954- ty_trait( d, _ , store, m, bounds) => {
4970+ ty_trait( ~ty :: TyTrait { def_id : d, store, mutability : m, bounds, .. } ) => {
49554971 byte ! ( 17 ) ;
49564972 did ( & mut state, d) ;
49574973 match store {
0 commit comments