@@ -4925,13 +4925,11 @@ pub fn trait_method_of_method(tcx: ctxt,
4925
4925
/// Creates a hash of the type `t` which will be the same no matter what crate
4926
4926
/// context it's calculated within. This is used by the `type_id` intrinsic.
4927
4927
pub 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) } ) ;
4929
4931
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 | {
4935
4933
match r {
4936
4934
ReStatic => { }
4937
4935
@@ -4945,27 +4943,27 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
4945
4943
}
4946
4944
}
4947
4945
} ;
4948
- let vstore = |hash : & mut sip:: SipState , v : vstore | {
4946
+ let vstore = |state : & mut sip:: SipState , v : vstore | {
4949
4947
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 ) ,
4952
4950
vstore_slice( r) => {
4953
- 2u8 . hash ( hash ) ;
4954
- region ( hash , r) ;
4951
+ 2u8 . hash ( state ) ;
4952
+ region ( state , r) ;
4955
4953
}
4956
4954
}
4957
4955
} ;
4958
- let did = |hash : & mut sip:: SipState , did : DefId | {
4956
+ let did = |state : & mut sip:: SipState , did : DefId | {
4959
4957
let h = if ast_util:: is_local ( did) {
4960
4958
local_hash. clone ( )
4961
4959
} else {
4962
4960
tcx. sess . cstore . get_crate_hash ( did. krate )
4963
4961
} ;
4964
- h. as_bytes ( ) . hash ( hash ) ;
4965
- did. node . hash ( hash ) ;
4962
+ h. as_bytes ( ) . hash ( state ) ;
4963
+ did. node . hash ( state ) ;
4966
4964
} ;
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 ) ;
4969
4967
} ;
4970
4968
ty:: walk_ty ( t, |t| {
4971
4969
match ty:: get ( t) . sty {
@@ -5001,17 +4999,17 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
5001
4999
}
5002
5000
ty_vec( m, v) => {
5003
5001
byte ! ( 11 ) ;
5004
- mt ( & mut hash , m) ;
5005
- vstore ( & mut hash , v) ;
5002
+ mt ( & mut state , m) ;
5003
+ vstore ( & mut state , v) ;
5006
5004
}
5007
5005
ty_ptr( m) => {
5008
5006
byte ! ( 12 ) ;
5009
- mt ( & mut hash , m) ;
5007
+ mt ( & mut state , m) ;
5010
5008
}
5011
5009
ty_rptr( r, m) => {
5012
5010
byte ! ( 13 ) ;
5013
- region ( & mut hash , r) ;
5014
- mt ( & mut hash , m) ;
5011
+ region ( & mut state , r) ;
5012
+ mt ( & mut state , m) ;
5015
5013
}
5016
5014
ty_bare_fn( ref b) => {
5017
5015
byte ! ( 14 ) ;
@@ -5024,24 +5022,24 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
5024
5022
hash ! ( c. sigil) ;
5025
5023
hash ! ( c. onceness) ;
5026
5024
hash ! ( c. bounds) ;
5027
- region ( & mut hash , c. region ) ;
5025
+ region ( & mut state , c. region ) ;
5028
5026
}
5029
5027
ty_trait( d, _, store, m, bounds) => {
5030
5028
byte ! ( 17 ) ;
5031
- did ( & mut hash , d) ;
5029
+ did ( & mut state , d) ;
5032
5030
match store {
5033
5031
UniqTraitStore => byte ! ( 0 ) ,
5034
5032
RegionTraitStore ( r) => {
5035
5033
byte ! ( 1 )
5036
- region ( & mut hash , r) ;
5034
+ region ( & mut state , r) ;
5037
5035
}
5038
5036
}
5039
5037
hash ! ( m) ;
5040
5038
hash ! ( bounds) ;
5041
5039
}
5042
5040
ty_struct( d, _) => {
5043
5041
byte ! ( 18 ) ;
5044
- did ( & mut hash , d) ;
5042
+ did ( & mut state , d) ;
5045
5043
}
5046
5044
ty_tup( ref inner) => {
5047
5045
byte ! ( 19 ) ;
@@ -5050,22 +5048,22 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
5050
5048
ty_param( p) => {
5051
5049
byte ! ( 20 ) ;
5052
5050
hash ! ( p. idx) ;
5053
- did ( & mut hash , p. def_id ) ;
5051
+ did ( & mut state , p. def_id ) ;
5054
5052
}
5055
5053
ty_self( d) => {
5056
5054
byte ! ( 21 ) ;
5057
- did ( & mut hash , d) ;
5055
+ did ( & mut state , d) ;
5058
5056
}
5059
5057
ty_infer( _) => unreachable ! ( ) ,
5060
5058
ty_err => byte ! ( 23 ) ,
5061
5059
ty_unboxed_vec( m) => {
5062
5060
byte ! ( 24 ) ;
5063
- mt ( & mut hash , m) ;
5061
+ mt ( & mut state , m) ;
5064
5062
}
5065
5063
}
5066
5064
} ) ;
5067
5065
5068
- hash . result ( )
5066
+ state . result ( )
5069
5067
}
5070
5068
5071
5069
impl Variance {
0 commit comments