@@ -522,7 +522,8 @@ pub enum sty {
522522 ty_tup( ~[ t ] ) ,
523523
524524 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 */
526527
527528 ty_infer( InferTy ) , // something used only during inference/typeck
528529 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 {
897898 & ty_err => flags |= has_ty_err as uint ,
898899 & ty_param( _) => flags |= has_params as uint ,
899900 & ty_infer( _) => flags |= needs_infer as uint ,
900- & ty_self => flags |= has_self as uint ,
901+ & ty_self( _ ) => flags |= has_self as uint ,
901902 & ty_enum( _, ref substs) | & ty_struct( _, ref substs) |
902903 & ty_trait( _, ref substs, _) => {
903904 flags |= sflags ( substs) ;
@@ -1082,7 +1083,7 @@ pub fn mk_float_var(cx: ctxt, v: FloatVid) -> t { mk_infer(cx, FloatVar(v)) }
10821083
10831084pub fn mk_infer ( cx : ctxt , +it : InferTy ) -> t { mk_t ( cx, ty_infer ( it) ) }
10841085
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 ) ) }
10861087
10871088pub fn mk_param ( cx : ctxt , n : uint , k : def_id ) -> t {
10881089 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) {
11631164 if !f ( ty) { return ; }
11641165 match get ( ty) . sty {
11651166 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( _ ) |
11671168 ty_opaque_closure_ptr( _) | ty_infer( _) | ty_param( _) | ty_err => {
11681169 }
11691170 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 {
12501251 }
12511252 ty_nil | ty_bot | ty_bool | ty_int( _) | ty_uint( _) | ty_float( _) |
12521253 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( _ ) => {
12541255 /*bad*/ copy * sty
12551256 }
12561257 }
@@ -1362,7 +1363,7 @@ pub fn subst_tps(cx: ctxt, tps: &[t], self_ty_opt: Option<t>, typ: t) -> t {
13621363 if self_ty_opt. is_none ( ) && !tbox_has_flag ( tb, has_params) { return typ; }
13631364 match tb. sty {
13641365 ty_param( p) => tps[ p. idx ] ,
1365- ty_self => {
1366+ ty_self( _ ) => {
13661367 match self_ty_opt {
13671368 None => cx. sess . bug ( ~"ty_self unexpected here") ,
13681369 Some ( self_ty) => {
@@ -1424,7 +1425,7 @@ pub fn subst(cx: ctxt,
14241425 if !tbox_has_flag(tb, needs_subst) { return typ; }
14251426 match tb.sty {
14261427 ty_param(p) => substs.tps[p.idx],
1427- ty_self => substs.self_ty.get(),
1428+ ty_self(_) => substs.self_ty.get(),
14281429 _ => {
14291430 fold_regions_and_ty(
14301431 cx, typ,
@@ -2002,7 +2003,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20022003 cx, cx.ty_param_bounds.get(&p.def_id.node))
20032004 }
20042005
2005- ty_self => {
2006+ ty_self(_) => {
20062007 // Currently, self is not bounded, so we must assume the
20072008 // worst. But in the future we should examine the super
20082009 // traits.
@@ -2159,7 +2160,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
21592160 v.args.foldl(0, |s, a| *s + type_size(cx, *a))))
21602161 }
21612162
2162- ty_param(_) | ty_self => {
2163+ ty_param(_) | ty_self(_) => {
21632164 1
21642165 }
21652166
@@ -2220,7 +2221,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
22202221 ty_infer(_) |
22212222 ty_err |
22222223 ty_param(_) |
2223- ty_self |
2224+ ty_self(_) |
22242225 ty_type |
22252226 ty_opaque_box |
22262227 ty_opaque_closure_ptr(_) |
@@ -2655,7 +2656,7 @@ impl to_bytes::IterBytes for sty {
26552656 ty_bare_fn(ref ft) =>
26562657 to_bytes::iter_bytes_2(&12u8, ft, lsb0, f),
26572658
2658- ty_self => 13u8.iter_bytes( lsb0, f),
2659+ ty_self(ref did) => to_bytes::iter_bytes_2(&13u8, did, lsb0, f),
26592660
26602661 ty_infer(ref v) =>
26612662 to_bytes::iter_bytes_2(&14u8, v, lsb0, f),
@@ -3341,7 +3342,7 @@ pub fn ty_sort_str(cx: ctxt, t: t) -> ~str {
33413342 ty_infer( IntVar ( _) ) => ~"integral variable",
33423343 ty_infer( FloatVar ( _) ) => ~"floating-point variable",
33433344 ty_param( _) => ~"type parameter",
3344- ty_self => ~"self ",
3345+ ty_self( _ ) => ~"self ",
33453346 ty_err => ~"type error"
33463347 }
33473348}
0 commit comments