@@ -4925,13 +4925,11 @@ pub fn trait_method_of_method(tcx: ctxt,
49254925/// Creates a hash of the type `t` which will be the same no matter what crate
49264926/// context it's calculated within. This is used by the `type_id` intrinsic.
49274927pub fn hash_crate_independent ( tcx : ctxt , t : t , local_hash : ~str ) -> u64 {
4928- use std:: hash:: { sip, Hash } ;
4928+ let mut state = sip:: SipState :: new ( 0 , 0 ) ;
4929+ macro_rules! byte( ( $b: expr) => { ( $b as u8 ) . hash( & mut state) } ) ;
4930+ macro_rules! hash( ( $e: expr) => { $e. hash( & mut state) } ) ;
49294931
4930- let mut hash = sip:: SipState :: new ( 0 , 0 ) ;
4931- macro_rules! byte( ( $b: expr) => { ( $b as u8 ) . hash( & mut hash) } ) ;
4932- macro_rules! hash( ( $e: expr) => { $e. hash( & mut hash) } ) ;
4933-
4934- let region = |_hash : & mut sip:: SipState , r : Region | {
4932+ let region = |_state : & mut sip:: SipState , r : Region | {
49354933 match r {
49364934 ReStatic => { }
49374935
@@ -4945,27 +4943,27 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
49454943 }
49464944 }
49474945 } ;
4948- let vstore = |hash : & mut sip:: SipState , v : vstore | {
4946+ let vstore = |state : & mut sip:: SipState , v : vstore | {
49494947 match v {
4950- vstore_fixed( _) => 0u8 . hash ( hash ) ,
4951- vstore_uniq => 1u8 . hash ( hash ) ,
4948+ vstore_fixed( _) => 0u8 . hash ( state ) ,
4949+ vstore_uniq => 1u8 . hash ( state ) ,
49524950 vstore_slice( r) => {
4953- 2u8 . hash ( hash ) ;
4954- region ( hash , r) ;
4951+ 2u8 . hash ( state ) ;
4952+ region ( state , r) ;
49554953 }
49564954 }
49574955 } ;
4958- let did = |hash : & mut sip:: SipState , did : DefId | {
4956+ let did = |state : & mut sip:: SipState , did : DefId | {
49594957 let h = if ast_util:: is_local ( did) {
49604958 local_hash. clone ( )
49614959 } else {
49624960 tcx. sess . cstore . get_crate_hash ( did. krate )
49634961 } ;
4964- h. as_bytes ( ) . hash ( hash ) ;
4965- did. node . hash ( hash ) ;
4962+ h. as_bytes ( ) . hash ( state ) ;
4963+ did. node . hash ( state ) ;
49664964 } ;
4967- let mt = |hash : & mut sip:: SipState , mt : mt | {
4968- mt. mutbl . hash ( hash ) ;
4965+ let mt = |state : & mut sip:: SipState , mt : mt | {
4966+ mt. mutbl . hash ( state ) ;
49694967 } ;
49704968 ty:: walk_ty ( t, |t| {
49714969 match ty:: get ( t) . sty {
@@ -5001,17 +4999,17 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
50014999 }
50025000 ty_vec( m, v) => {
50035001 byte ! ( 11 ) ;
5004- mt ( & mut hash , m) ;
5005- vstore ( & mut hash , v) ;
5002+ mt ( & mut state , m) ;
5003+ vstore ( & mut state , v) ;
50065004 }
50075005 ty_ptr( m) => {
50085006 byte ! ( 12 ) ;
5009- mt ( & mut hash , m) ;
5007+ mt ( & mut state , m) ;
50105008 }
50115009 ty_rptr( r, m) => {
50125010 byte ! ( 13 ) ;
5013- region ( & mut hash , r) ;
5014- mt ( & mut hash , m) ;
5011+ region ( & mut state , r) ;
5012+ mt ( & mut state , m) ;
50155013 }
50165014 ty_bare_fn( ref b) => {
50175015 byte ! ( 14 ) ;
@@ -5024,24 +5022,24 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
50245022 hash ! ( c. sigil) ;
50255023 hash ! ( c. onceness) ;
50265024 hash ! ( c. bounds) ;
5027- region ( & mut hash , c. region ) ;
5025+ region ( & mut state , c. region ) ;
50285026 }
50295027 ty_trait( d, _, store, m, bounds) => {
50305028 byte ! ( 17 ) ;
5031- did ( & mut hash , d) ;
5029+ did ( & mut state , d) ;
50325030 match store {
50335031 UniqTraitStore => byte ! ( 0 ) ,
50345032 RegionTraitStore ( r) => {
50355033 byte ! ( 1 )
5036- region ( & mut hash , r) ;
5034+ region ( & mut state , r) ;
50375035 }
50385036 }
50395037 hash ! ( m) ;
50405038 hash ! ( bounds) ;
50415039 }
50425040 ty_struct( d, _) => {
50435041 byte ! ( 18 ) ;
5044- did ( & mut hash , d) ;
5042+ did ( & mut state , d) ;
50455043 }
50465044 ty_tup( ref inner) => {
50475045 byte ! ( 19 ) ;
@@ -5050,22 +5048,22 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
50505048 ty_param( p) => {
50515049 byte ! ( 20 ) ;
50525050 hash ! ( p. idx) ;
5053- did ( & mut hash , p. def_id ) ;
5051+ did ( & mut state , p. def_id ) ;
50545052 }
50555053 ty_self( d) => {
50565054 byte ! ( 21 ) ;
5057- did ( & mut hash , d) ;
5055+ did ( & mut state , d) ;
50585056 }
50595057 ty_infer( _) => unreachable ! ( ) ,
50605058 ty_err => byte ! ( 23 ) ,
50615059 ty_unboxed_vec( m) => {
50625060 byte ! ( 24 ) ;
5063- mt ( & mut hash , m) ;
5061+ mt ( & mut state , m) ;
50645062 }
50655063 }
50665064 } ) ;
50675065
5068- hash . result ( )
5066+ state . result ( )
50695067}
50705068
50715069impl Variance {
0 commit comments