@@ -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 > > > ,
@@ -600,7 +599,6 @@ bitflags! {
600599#[ deriving( Show ) ]
601600pub struct TyS < ' tcx > {
602601 pub sty : sty < ' tcx > ,
603- pub id : uint ,
604602 pub flags : TypeFlags ,
605603}
606604
@@ -665,7 +663,6 @@ pub fn type_has_ty_infer(ty: Ty) -> bool {
665663pub fn type_needs_infer ( ty : Ty ) -> bool {
666664 tbox_has_flag ( ty, HAS_TY_INFER | HAS_RE_INFER )
667665}
668- pub fn type_id ( ty : Ty ) -> uint { ty. id }
669666
670667
671668#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
@@ -944,38 +941,34 @@ mod primitives {
944941 use syntax:: ast;
945942
946943 macro_rules! def_prim_ty(
947- ( $name: ident, $sty: expr, $id : expr ) => (
944+ ( $name: ident, $sty: expr) => (
948945 pub static $name: TyS <' static > = TyS {
949946 sty: $sty,
950- id: $id,
951947 flags: super :: NO_TYPE_FLAGS ,
952948 } ;
953949 )
954950 )
955951
956- def_prim_ty ! ( TY_NIL , super :: ty_nil, 0 )
957- def_prim_ty ! ( TY_BOOL , super :: ty_bool, 1 )
958- def_prim_ty ! ( TY_CHAR , super :: ty_char, 2 )
959- def_prim_ty ! ( TY_INT , super :: ty_int( ast:: TyI ) , 3 )
960- def_prim_ty ! ( TY_I8 , super :: ty_int( ast:: TyI8 ) , 4 )
961- def_prim_ty ! ( TY_I16 , super :: ty_int( ast:: TyI16 ) , 5 )
962- def_prim_ty ! ( TY_I32 , super :: ty_int( ast:: TyI32 ) , 6 )
963- def_prim_ty ! ( TY_I64 , super :: ty_int( ast:: TyI64 ) , 7 )
964- def_prim_ty ! ( TY_UINT , super :: ty_uint( ast:: TyU ) , 8 )
965- def_prim_ty ! ( TY_U8 , super :: ty_uint( ast:: TyU8 ) , 9 )
966- def_prim_ty ! ( TY_U16 , super :: ty_uint( ast:: TyU16 ) , 10 )
967- def_prim_ty ! ( TY_U32 , super :: ty_uint( ast:: TyU32 ) , 11 )
968- def_prim_ty ! ( TY_U64 , super :: ty_uint( ast:: TyU64 ) , 12 )
969- def_prim_ty ! ( TY_F32 , super :: ty_float( ast:: TyF32 ) , 14 )
970- def_prim_ty ! ( TY_F64 , super :: ty_float( ast:: TyF64 ) , 15 )
952+ def_prim_ty ! ( TY_NIL , super :: ty_nil)
953+ def_prim_ty ! ( TY_BOOL , super :: ty_bool)
954+ def_prim_ty ! ( TY_CHAR , super :: ty_char)
955+ def_prim_ty ! ( TY_INT , super :: ty_int( ast:: TyI ) )
956+ def_prim_ty ! ( TY_I8 , super :: ty_int( ast:: TyI8 ) )
957+ def_prim_ty ! ( TY_I16 , super :: ty_int( ast:: TyI16 ) )
958+ def_prim_ty ! ( TY_I32 , super :: ty_int( ast:: TyI32 ) )
959+ def_prim_ty ! ( TY_I64 , super :: ty_int( ast:: TyI64 ) )
960+ def_prim_ty ! ( TY_UINT , super :: ty_uint( ast:: TyU ) )
961+ def_prim_ty ! ( TY_U8 , super :: ty_uint( ast:: TyU8 ) )
962+ def_prim_ty ! ( TY_U16 , super :: ty_uint( ast:: TyU16 ) )
963+ def_prim_ty ! ( TY_U32 , super :: ty_uint( ast:: TyU32 ) )
964+ def_prim_ty ! ( TY_U64 , super :: ty_uint( ast:: TyU64 ) )
965+ def_prim_ty ! ( TY_F32 , super :: ty_float( ast:: TyF32 ) )
966+ def_prim_ty ! ( TY_F64 , super :: ty_float( ast:: TyF64 ) )
971967
972968 pub static TY_ERR : TyS < ' static > = TyS {
973969 sty : super :: ty_err,
974- id : 17 ,
975970 flags : super :: HAS_TY_ERR ,
976971 } ;
977-
978- pub const LAST_PRIMITIVE_ID : uint = 18 ;
979972}
980973
981974// NB: If you change this, you'll probably want to change the corresponding
@@ -1591,7 +1584,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
15911584 named_region_map : named_region_map,
15921585 item_variance_map : RefCell :: new ( DefIdMap :: new ( ) ) ,
15931586 variance_computed : Cell :: new ( false ) ,
1594- next_id : Cell :: new ( primitives:: LAST_PRIMITIVE_ID ) ,
15951587 sess : s,
15961588 def_map : dm,
15971589 region_maps : region_maps,
@@ -1755,14 +1747,11 @@ pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
17551747
17561748 let ty = cx. type_arena . alloc ( TyS {
17571749 sty : st,
1758- id : cx. next_id . get ( ) ,
17591750 flags : flags,
17601751 } ) ;
17611752
17621753 cx. interner . borrow_mut ( ) . insert ( InternedTy { ty : ty } , ty) ;
17631754
1764- cx. next_id . set ( cx. next_id . get ( ) + 1 ) ;
1765-
17661755 ty
17671756}
17681757
@@ -2469,13 +2458,13 @@ pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
24692458}
24702459
24712460pub fn type_contents < ' tcx > ( cx : & ctxt < ' tcx > , ty : Ty < ' tcx > ) -> TypeContents {
2472- return memoized_with_key ( & cx. tc_cache , ty, |ty| {
2461+ return memoized ( & cx. tc_cache , ty, |ty| {
24732462 tc_ty ( cx, ty, & mut HashMap :: new ( ) )
2474- } , | & ty| type_id ( ty ) ) ;
2463+ } ) ;
24752464
24762465 fn tc_ty < ' tcx > ( cx : & ctxt < ' tcx > ,
24772466 ty : Ty < ' tcx > ,
2478- cache : & mut HashMap < uint , TypeContents > ) -> TypeContents
2467+ cache : & mut HashMap < Ty < ' tcx > , TypeContents > ) -> TypeContents
24792468 {
24802469 // Subtle: Note that we are *not* using cx.tc_cache here but rather a
24812470 // private cache for this walk. This is needed in the case of cyclic
@@ -2498,16 +2487,15 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
24982487 // which is incorrect. This value was computed based on the crutch
24992488 // value for the type contents of list. The correct value is
25002489 // TC::OwnsOwned. This manifested as issue #4821.
2501- let ty_id = type_id ( ty) ;
2502- match cache. find ( & ty_id) {
2490+ match cache. find ( & ty) {
25032491 Some ( tc) => { return * tc; }
25042492 None => { }
25052493 }
2506- match cx. tc_cache . borrow ( ) . find ( & ty_id ) { // Must check both caches!
2494+ match cx. tc_cache . borrow ( ) . find ( & ty ) { // Must check both caches!
25072495 Some ( tc) => { return * tc; }
25082496 None => { }
25092497 }
2510- cache. insert ( ty_id , TC :: None ) ;
2498+ cache. insert ( ty , TC :: None ) ;
25112499
25122500 let result = match ty. sty {
25132501 // uint and int are ffi-unsafe
@@ -2677,13 +2665,13 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
26772665 }
26782666 } ;
26792667
2680- cache. insert ( ty_id , result) ;
2681- return result;
2668+ cache. insert ( ty , result) ;
2669+ result
26822670 }
26832671
26842672 fn tc_mt < ' tcx > ( cx : & ctxt < ' tcx > ,
26852673 mt : mt < ' tcx > ,
2686- cache : & mut HashMap < uint , TypeContents > ) -> TypeContents
2674+ cache : & mut HashMap < Ty < ' tcx > , TypeContents > ) -> TypeContents
26872675 {
26882676 let mc = TC :: ReachesMutable . when ( mt. mutbl == MutMutable ) ;
26892677 mc | tc_ty ( cx, mt. ty , cache)
@@ -2992,7 +2980,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
29922980 pairs. all ( |( & a, & b) | same_type ( a, b) )
29932981 }
29942982 _ => {
2995- type_id ( a ) == type_id ( b )
2983+ a == b
29962984 }
29972985 }
29982986 }
0 commit comments