@@ -747,7 +747,7 @@ pub enum sty {
747747 ty_rptr( Region , mt ) ,
748748 ty_bare_fn( BareFnTy ) ,
749749 ty_closure( ClosureTy ) ,
750- ty_trait( DefId , substs , TraitStore , ast :: Mutability , BuiltinBounds ) ,
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 _ => { }
@@ -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) ) ; } }
@@ -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
@@ -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