@@ -32,7 +32,7 @@ use middle;
3232use util:: ppaux:: { note_and_explain_region, bound_region_ptr_to_string} ;
3333use util:: ppaux:: { trait_store_to_string, ty_to_string} ;
3434use util:: ppaux:: { Repr , UserString } ;
35- use util:: common:: { indenter, memoized, memoized_with_key } ;
35+ use util:: common:: { indenter, memoized} ;
3636use util:: nodemap:: { NodeMap , NodeSet , DefIdMap , DefIdSet , FnvHashMap } ;
3737
3838use std:: cell:: { Cell , RefCell } ;
@@ -437,7 +437,6 @@ pub struct ctxt<'tcx> {
437437 // FIXME(eddyb) use a FnvHashSet<InternedTy<'tcx>> when equivalent keys can
438438 // queried from a HashSet.
439439 interner : RefCell < FnvHashMap < InternedTy < ' tcx > , Ty < ' tcx > > > ,
440- pub next_id : Cell < uint > ,
441440 pub sess : Session ,
442441 pub def_map : resolve:: DefMap ,
443442
@@ -481,7 +480,7 @@ pub struct ctxt<'tcx> {
481480 pub rcache : creader_cache < ' tcx > ,
482481 pub short_names_cache : RefCell < HashMap < Ty < ' tcx > , String > > ,
483482 pub needs_unwind_cleanup_cache : RefCell < HashMap < Ty < ' tcx > , bool > > ,
484- pub tc_cache : RefCell < HashMap < uint , TypeContents > > ,
483+ pub tc_cache : RefCell < HashMap < Ty < ' tcx > , TypeContents > > ,
485484 pub ast_ty_to_ty_cache : RefCell < NodeMap < ast_ty_to_ty_cache_entry < ' tcx > > > ,
486485 pub enum_var_cache : RefCell < DefIdMap < Rc < Vec < Rc < VariantInfo < ' tcx > > > > > > ,
487486 pub ty_param_defs : RefCell < NodeMap < TypeParameterDef < ' tcx > > > ,
@@ -604,7 +603,6 @@ bitflags! {
604603#[ deriving( Show ) ]
605604pub struct TyS < ' tcx > {
606605 pub sty : sty < ' tcx > ,
607- pub id : uint ,
608606 pub flags : TypeFlags ,
609607}
610608
@@ -669,7 +667,6 @@ pub fn type_has_ty_infer(ty: Ty) -> bool {
669667pub fn type_needs_infer ( ty : Ty ) -> bool {
670668 tbox_has_flag ( ty, HAS_TY_INFER | HAS_RE_INFER )
671669}
672- pub fn type_id ( ty : Ty ) -> uint { ty. id }
673670
674671
675672#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
@@ -948,38 +945,34 @@ mod primitives {
948945 use syntax:: ast;
949946
950947 macro_rules! def_prim_ty(
951- ( $name: ident, $sty: expr, $id : expr ) => (
948+ ( $name: ident, $sty: expr) => (
952949 pub static $name: TyS <' static > = TyS {
953950 sty: $sty,
954- id: $id,
955951 flags: super :: NO_TYPE_FLAGS ,
956952 } ;
957953 )
958954 )
959955
960- def_prim_ty ! ( TY_NIL , super :: ty_nil, 0 )
961- def_prim_ty ! ( TY_BOOL , super :: ty_bool, 1 )
962- def_prim_ty ! ( TY_CHAR , super :: ty_char, 2 )
963- def_prim_ty ! ( TY_INT , super :: ty_int( ast:: TyI ) , 3 )
964- def_prim_ty ! ( TY_I8 , super :: ty_int( ast:: TyI8 ) , 4 )
965- def_prim_ty ! ( TY_I16 , super :: ty_int( ast:: TyI16 ) , 5 )
966- def_prim_ty ! ( TY_I32 , super :: ty_int( ast:: TyI32 ) , 6 )
967- def_prim_ty ! ( TY_I64 , super :: ty_int( ast:: TyI64 ) , 7 )
968- def_prim_ty ! ( TY_UINT , super :: ty_uint( ast:: TyU ) , 8 )
969- def_prim_ty ! ( TY_U8 , super :: ty_uint( ast:: TyU8 ) , 9 )
970- def_prim_ty ! ( TY_U16 , super :: ty_uint( ast:: TyU16 ) , 10 )
971- def_prim_ty ! ( TY_U32 , super :: ty_uint( ast:: TyU32 ) , 11 )
972- def_prim_ty ! ( TY_U64 , super :: ty_uint( ast:: TyU64 ) , 12 )
973- def_prim_ty ! ( TY_F32 , super :: ty_float( ast:: TyF32 ) , 14 )
974- def_prim_ty ! ( TY_F64 , super :: ty_float( ast:: TyF64 ) , 15 )
956+ def_prim_ty ! ( TY_NIL , super :: ty_nil)
957+ def_prim_ty ! ( TY_BOOL , super :: ty_bool)
958+ def_prim_ty ! ( TY_CHAR , super :: ty_char)
959+ def_prim_ty ! ( TY_INT , super :: ty_int( ast:: TyI ) )
960+ def_prim_ty ! ( TY_I8 , super :: ty_int( ast:: TyI8 ) )
961+ def_prim_ty ! ( TY_I16 , super :: ty_int( ast:: TyI16 ) )
962+ def_prim_ty ! ( TY_I32 , super :: ty_int( ast:: TyI32 ) )
963+ def_prim_ty ! ( TY_I64 , super :: ty_int( ast:: TyI64 ) )
964+ def_prim_ty ! ( TY_UINT , super :: ty_uint( ast:: TyU ) )
965+ def_prim_ty ! ( TY_U8 , super :: ty_uint( ast:: TyU8 ) )
966+ def_prim_ty ! ( TY_U16 , super :: ty_uint( ast:: TyU16 ) )
967+ def_prim_ty ! ( TY_U32 , super :: ty_uint( ast:: TyU32 ) )
968+ def_prim_ty ! ( TY_U64 , super :: ty_uint( ast:: TyU64 ) )
969+ def_prim_ty ! ( TY_F32 , super :: ty_float( ast:: TyF32 ) )
970+ def_prim_ty ! ( TY_F64 , super :: ty_float( ast:: TyF64 ) )
975971
976972 pub static TY_ERR : TyS < ' static > = TyS {
977973 sty : super :: ty_err,
978- id : 17 ,
979974 flags : super :: HAS_TY_ERR ,
980975 } ;
981-
982- pub const LAST_PRIMITIVE_ID : uint = 18 ;
983976}
984977
985978// NB: If you change this, you'll probably want to change the corresponding
@@ -1595,7 +1588,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
15951588 named_region_map : named_region_map,
15961589 item_variance_map : RefCell :: new ( DefIdMap :: new ( ) ) ,
15971590 variance_computed : Cell :: new ( false ) ,
1598- next_id : Cell :: new ( primitives:: LAST_PRIMITIVE_ID ) ,
15991591 sess : s,
16001592 def_map : dm,
16011593 region_maps : region_maps,
@@ -1760,14 +1752,11 @@ pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
17601752
17611753 let ty = cx. type_arena . alloc ( TyS {
17621754 sty : st,
1763- id : cx. next_id . get ( ) ,
17641755 flags : flags,
17651756 } ) ;
17661757
17671758 cx. interner . borrow_mut ( ) . insert ( InternedTy { ty : ty } , ty) ;
17681759
1769- cx. next_id . set ( cx. next_id . get ( ) + 1 ) ;
1770-
17711760 ty
17721761}
17731762
@@ -2464,13 +2453,13 @@ pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
24642453}
24652454
24662455pub fn type_contents < ' tcx > ( cx : & ctxt < ' tcx > , ty : Ty < ' tcx > ) -> TypeContents {
2467- return memoized_with_key ( & cx. tc_cache , ty, |ty| {
2456+ return memoized ( & cx. tc_cache , ty, |ty| {
24682457 tc_ty ( cx, ty, & mut HashMap :: new ( ) )
2469- } , | & ty| type_id ( ty ) ) ;
2458+ } ) ;
24702459
24712460 fn tc_ty < ' tcx > ( cx : & ctxt < ' tcx > ,
24722461 ty : Ty < ' tcx > ,
2473- cache : & mut HashMap < uint , TypeContents > ) -> TypeContents
2462+ cache : & mut HashMap < Ty < ' tcx > , TypeContents > ) -> TypeContents
24742463 {
24752464 // Subtle: Note that we are *not* using cx.tc_cache here but rather a
24762465 // private cache for this walk. This is needed in the case of cyclic
@@ -2493,16 +2482,15 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
24932482 // which is incorrect. This value was computed based on the crutch
24942483 // value for the type contents of list. The correct value is
24952484 // TC::OwnsOwned. This manifested as issue #4821.
2496- let ty_id = type_id ( ty) ;
2497- match cache. find ( & ty_id) {
2485+ match cache. find ( & ty) {
24982486 Some ( tc) => { return * tc; }
24992487 None => { }
25002488 }
2501- match cx. tc_cache . borrow ( ) . find ( & ty_id ) { // Must check both caches!
2489+ match cx. tc_cache . borrow ( ) . find ( & ty ) { // Must check both caches!
25022490 Some ( tc) => { return * tc; }
25032491 None => { }
25042492 }
2505- cache. insert ( ty_id , TC :: None ) ;
2493+ cache. insert ( ty , TC :: None ) ;
25062494
25072495 let result = match ty. sty {
25082496 // uint and int are ffi-unsafe
@@ -2672,13 +2660,13 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
26722660 }
26732661 } ;
26742662
2675- cache. insert ( ty_id , result) ;
2676- return result;
2663+ cache. insert ( ty , result) ;
2664+ result
26772665 }
26782666
26792667 fn tc_mt < ' tcx > ( cx : & ctxt < ' tcx > ,
26802668 mt : mt < ' tcx > ,
2681- cache : & mut HashMap < uint , TypeContents > ) -> TypeContents
2669+ cache : & mut HashMap < Ty < ' tcx > , TypeContents > ) -> TypeContents
26822670 {
26832671 let mc = TC :: ReachesMutable . when ( mt. mutbl == MutMutable ) ;
26842672 mc | tc_ty ( cx, mt. ty , cache)
@@ -2987,7 +2975,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
29872975 pairs. all ( |( & a, & b) | same_type ( a, b) )
29882976 }
29892977 _ => {
2990- type_id ( a ) == type_id ( b )
2978+ a == b
29912979 }
29922980 }
29932981 }
0 commit comments