@@ -522,7 +522,8 @@ pub enum sty {
522
522
ty_tup( ~[ t ] ) ,
523
523
524
524
ty_param( param_ty ) , // type parameter
525
- ty_self, // special, implicit `self` type parameter
525
+ ty_self( def_id ) , /* special, implicit `self` type parameter;
526
+ * def_id is the id of the trait */
526
527
527
528
ty_infer( InferTy ) , // something used only during inference/typeck
528
529
ty_err, // Also only used during inference/typeck, to represent
@@ -897,7 +898,7 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
897
898
& ty_err => flags |= has_ty_err as uint ,
898
899
& ty_param( _) => flags |= has_params as uint ,
899
900
& ty_infer( _) => flags |= needs_infer as uint ,
900
- & ty_self => flags |= has_self as uint ,
901
+ & ty_self( _ ) => flags |= has_self as uint ,
901
902
& ty_enum( _, ref substs) | & ty_struct( _, ref substs) |
902
903
& ty_trait( _, ref substs, _) => {
903
904
flags |= sflags ( substs) ;
@@ -1082,7 +1083,7 @@ pub fn mk_float_var(cx: ctxt, v: FloatVid) -> t { mk_infer(cx, FloatVar(v)) }
1082
1083
1083
1084
pub fn mk_infer ( cx : ctxt , +it : InferTy ) -> t { mk_t ( cx, ty_infer ( it) ) }
1084
1085
1085
- pub fn mk_self ( cx : ctxt ) -> t { mk_t ( cx, ty_self) }
1086
+ pub fn mk_self ( cx : ctxt , did : ast :: def_id ) -> t { mk_t ( cx, ty_self ( did ) ) }
1086
1087
1087
1088
pub fn mk_param ( cx : ctxt , n : uint , k : def_id ) -> t {
1088
1089
mk_t ( cx, ty_param ( param_ty { idx : n, def_id : k } ) )
@@ -1163,7 +1164,7 @@ pub fn maybe_walk_ty(ty: t, f: &fn(t) -> bool) {
1163
1164
if !f ( ty) { return ; }
1164
1165
match get ( ty) . sty {
1165
1166
ty_nil | ty_bot | ty_bool | ty_int( _) | ty_uint( _) | ty_float( _) |
1166
- ty_estr( _) | ty_type | ty_opaque_box | ty_self |
1167
+ ty_estr( _) | ty_type | ty_opaque_box | ty_self( _ ) |
1167
1168
ty_opaque_closure_ptr( _) | ty_infer( _) | ty_param( _) | ty_err => {
1168
1169
}
1169
1170
ty_box( ref tm) | ty_evec( ref tm, _) | ty_unboxed_vec( ref tm) |
@@ -1250,7 +1251,7 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty {
1250
1251
}
1251
1252
ty_nil | ty_bot | ty_bool | ty_int( _) | ty_uint( _) | ty_float( _) |
1252
1253
ty_estr( _) | ty_type | ty_opaque_closure_ptr( _) | ty_err |
1253
- ty_opaque_box | ty_infer( _) | ty_param( * ) | ty_self => {
1254
+ ty_opaque_box | ty_infer( _) | ty_param( * ) | ty_self( _ ) => {
1254
1255
/*bad*/ copy * sty
1255
1256
}
1256
1257
}
@@ -1362,7 +1363,7 @@ pub fn subst_tps(cx: ctxt, tps: &[t], self_ty_opt: Option<t>, typ: t) -> t {
1362
1363
if self_ty_opt. is_none ( ) && !tbox_has_flag ( tb, has_params) { return typ; }
1363
1364
match tb. sty {
1364
1365
ty_param( p) => tps[ p. idx ] ,
1365
- ty_self => {
1366
+ ty_self( _ ) => {
1366
1367
match self_ty_opt {
1367
1368
None => cx. sess . bug ( ~"ty_self unexpected here") ,
1368
1369
Some ( self_ty) => {
@@ -1424,7 +1425,7 @@ pub fn subst(cx: ctxt,
1424
1425
if !tbox_has_flag(tb, needs_subst) { return typ; }
1425
1426
match tb.sty {
1426
1427
ty_param(p) => substs.tps[p.idx],
1427
- ty_self => substs.self_ty.get(),
1428
+ ty_self(_) => substs.self_ty.get(),
1428
1429
_ => {
1429
1430
fold_regions_and_ty(
1430
1431
cx, typ,
@@ -2002,7 +2003,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2002
2003
cx, cx.ty_param_bounds.get(&p.def_id.node))
2003
2004
}
2004
2005
2005
- ty_self => {
2006
+ ty_self(_) => {
2006
2007
// Currently, self is not bounded, so we must assume the
2007
2008
// worst. But in the future we should examine the super
2008
2009
// traits.
@@ -2159,7 +2160,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2159
2160
v.args.foldl(0, |s, a| *s + type_size(cx, *a))))
2160
2161
}
2161
2162
2162
- ty_param(_) | ty_self => {
2163
+ ty_param(_) | ty_self(_) => {
2163
2164
1
2164
2165
}
2165
2166
@@ -2220,7 +2221,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
2220
2221
ty_infer(_) |
2221
2222
ty_err |
2222
2223
ty_param(_) |
2223
- ty_self |
2224
+ ty_self(_) |
2224
2225
ty_type |
2225
2226
ty_opaque_box |
2226
2227
ty_opaque_closure_ptr(_) |
@@ -2655,7 +2656,7 @@ impl to_bytes::IterBytes for sty {
2655
2656
ty_bare_fn(ref ft) =>
2656
2657
to_bytes::iter_bytes_2(&12u8, ft, lsb0, f),
2657
2658
2658
- ty_self => 13u8.iter_bytes( lsb0, f),
2659
+ ty_self(ref did) => to_bytes::iter_bytes_2(&13u8, did, lsb0, f),
2659
2660
2660
2661
ty_infer(ref v) =>
2661
2662
to_bytes::iter_bytes_2(&14u8, v, lsb0, f),
@@ -3341,7 +3342,7 @@ pub fn ty_sort_str(cx: ctxt, t: t) -> ~str {
3341
3342
ty_infer( IntVar ( _) ) => ~"integral variable",
3342
3343
ty_infer( FloatVar ( _) ) => ~"floating-point variable",
3343
3344
ty_param( _) => ~"type parameter",
3344
- ty_self => ~"self ",
3345
+ ty_self( _ ) => ~"self ",
3345
3346
ty_err => ~"type error"
3346
3347
}
3347
3348
}
0 commit comments