@@ -32,7 +32,7 @@ use middle;
32
32
use util:: ppaux:: { note_and_explain_region, bound_region_ptr_to_string} ;
33
33
use util:: ppaux:: { trait_store_to_string, ty_to_string} ;
34
34
use util:: ppaux:: { Repr , UserString } ;
35
- use util:: common:: { indenter, memoized, memoized_with_key } ;
35
+ use util:: common:: { indenter, memoized} ;
36
36
use util:: nodemap:: { NodeMap , NodeSet , DefIdMap , DefIdSet , FnvHashMap } ;
37
37
38
38
use std:: cell:: { Cell , RefCell } ;
@@ -437,7 +437,6 @@ pub struct ctxt<'tcx> {
437
437
// FIXME(eddyb) use a FnvHashSet<InternedTy<'tcx>> when equivalent keys can
438
438
// queried from a HashSet.
439
439
interner : RefCell < FnvHashMap < InternedTy < ' tcx > , Ty < ' tcx > > > ,
440
- pub next_id : Cell < uint > ,
441
440
pub sess : Session ,
442
441
pub def_map : resolve:: DefMap ,
443
442
@@ -481,7 +480,7 @@ pub struct ctxt<'tcx> {
481
480
pub rcache : creader_cache < ' tcx > ,
482
481
pub short_names_cache : RefCell < HashMap < Ty < ' tcx > , String > > ,
483
482
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 > > ,
485
484
pub ast_ty_to_ty_cache : RefCell < NodeMap < ast_ty_to_ty_cache_entry < ' tcx > > > ,
486
485
pub enum_var_cache : RefCell < DefIdMap < Rc < Vec < Rc < VariantInfo < ' tcx > > > > > > ,
487
486
pub ty_param_defs : RefCell < NodeMap < TypeParameterDef < ' tcx > > > ,
@@ -600,7 +599,6 @@ bitflags! {
600
599
#[ deriving( Show ) ]
601
600
pub struct TyS < ' tcx > {
602
601
pub sty : sty < ' tcx > ,
603
- pub id : uint ,
604
602
pub flags : TypeFlags ,
605
603
}
606
604
@@ -665,7 +663,6 @@ pub fn type_has_ty_infer(ty: Ty) -> bool {
665
663
pub fn type_needs_infer ( ty : Ty ) -> bool {
666
664
tbox_has_flag ( ty, HAS_TY_INFER | HAS_RE_INFER )
667
665
}
668
- pub fn type_id ( ty : Ty ) -> uint { ty. id }
669
666
670
667
671
668
#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
@@ -944,38 +941,34 @@ mod primitives {
944
941
use syntax:: ast;
945
942
946
943
macro_rules! def_prim_ty(
947
- ( $name: ident, $sty: expr, $id : expr ) => (
944
+ ( $name: ident, $sty: expr) => (
948
945
pub static $name: TyS <' static > = TyS {
949
946
sty: $sty,
950
- id: $id,
951
947
flags: super :: NO_TYPE_FLAGS ,
952
948
} ;
953
949
)
954
950
)
955
951
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 ) )
971
967
972
968
pub static TY_ERR : TyS < ' static > = TyS {
973
969
sty : super :: ty_err,
974
- id : 17 ,
975
970
flags : super :: HAS_TY_ERR ,
976
971
} ;
977
-
978
- pub const LAST_PRIMITIVE_ID : uint = 18 ;
979
972
}
980
973
981
974
// NB: If you change this, you'll probably want to change the corresponding
@@ -1591,7 +1584,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
1591
1584
named_region_map : named_region_map,
1592
1585
item_variance_map : RefCell :: new ( DefIdMap :: new ( ) ) ,
1593
1586
variance_computed : Cell :: new ( false ) ,
1594
- next_id : Cell :: new ( primitives:: LAST_PRIMITIVE_ID ) ,
1595
1587
sess : s,
1596
1588
def_map : dm,
1597
1589
region_maps : region_maps,
@@ -1755,14 +1747,11 @@ pub fn mk_t<'tcx>(cx: &ctxt<'tcx>, st: sty<'tcx>) -> Ty<'tcx> {
1755
1747
1756
1748
let ty = cx. type_arena . alloc ( TyS {
1757
1749
sty : st,
1758
- id : cx. next_id . get ( ) ,
1759
1750
flags : flags,
1760
1751
} ) ;
1761
1752
1762
1753
cx. interner . borrow_mut ( ) . insert ( InternedTy { ty : ty } , ty) ;
1763
1754
1764
- cx. next_id . set ( cx. next_id . get ( ) + 1 ) ;
1765
-
1766
1755
ty
1767
1756
}
1768
1757
@@ -2469,13 +2458,13 @@ pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
2469
2458
}
2470
2459
2471
2460
pub 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| {
2473
2462
tc_ty ( cx, ty, & mut HashMap :: new ( ) )
2474
- } , | & ty| type_id ( ty ) ) ;
2463
+ } ) ;
2475
2464
2476
2465
fn tc_ty < ' tcx > ( cx : & ctxt < ' tcx > ,
2477
2466
ty : Ty < ' tcx > ,
2478
- cache : & mut HashMap < uint , TypeContents > ) -> TypeContents
2467
+ cache : & mut HashMap < Ty < ' tcx > , TypeContents > ) -> TypeContents
2479
2468
{
2480
2469
// Subtle: Note that we are *not* using cx.tc_cache here but rather a
2481
2470
// 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 {
2498
2487
// which is incorrect. This value was computed based on the crutch
2499
2488
// value for the type contents of list. The correct value is
2500
2489
// 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) {
2503
2491
Some ( tc) => { return * tc; }
2504
2492
None => { }
2505
2493
}
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!
2507
2495
Some ( tc) => { return * tc; }
2508
2496
None => { }
2509
2497
}
2510
- cache. insert ( ty_id , TC :: None ) ;
2498
+ cache. insert ( ty , TC :: None ) ;
2511
2499
2512
2500
let result = match ty. sty {
2513
2501
// uint and int are ffi-unsafe
@@ -2677,13 +2665,13 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
2677
2665
}
2678
2666
} ;
2679
2667
2680
- cache. insert ( ty_id , result) ;
2681
- return result;
2668
+ cache. insert ( ty , result) ;
2669
+ result
2682
2670
}
2683
2671
2684
2672
fn tc_mt < ' tcx > ( cx : & ctxt < ' tcx > ,
2685
2673
mt : mt < ' tcx > ,
2686
- cache : & mut HashMap < uint , TypeContents > ) -> TypeContents
2674
+ cache : & mut HashMap < Ty < ' tcx > , TypeContents > ) -> TypeContents
2687
2675
{
2688
2676
let mc = TC :: ReachesMutable . when ( mt. mutbl == MutMutable ) ;
2689
2677
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>)
2992
2980
pairs. all ( |( & a, & b) | same_type ( a, b) )
2993
2981
}
2994
2982
_ => {
2995
- type_id ( a ) == type_id ( b )
2983
+ a == b
2996
2984
}
2997
2985
}
2998
2986
}
0 commit comments