@@ -150,7 +150,7 @@ pub struct field_ty {
150
150
151
151
// Contains information needed to resolve types and (in the future) look up
152
152
// the types of AST nodes.
153
- #[ deriving( Eq , Hash ) ]
153
+ #[ deriving( Eq , Hash ) ]
154
154
pub struct creader_cache_key {
155
155
cnum : CrateNum ,
156
156
pos : uint ,
@@ -4926,13 +4926,11 @@ pub fn trait_method_of_method(tcx: ctxt,
4926
4926
/// Creates a hash of the type `t` which will be the same no matter what crate
4927
4927
/// context it's calculated within. This is used by the `type_id` intrinsic.
4928
4928
pub fn hash_crate_independent ( tcx : ctxt , t : t , local_hash : ~str ) -> u64 {
4929
- use std:: hash:: { sip, Hash } ;
4930
-
4931
- let mut hash = sip:: SipState :: new ( 0 , 0 ) ;
4932
- macro_rules! byte( ( $b: expr) => { ( $b as u8 ) . hash( & mut hash) } ) ;
4933
- macro_rules! hash( ( $e: expr) => { $e. hash( & mut hash) } ) ;
4929
+ let mut state = sip:: SipState :: new ( 0 , 0 ) ;
4930
+ macro_rules! byte( ( $b: expr) => { ( $b as u8 ) . hash( & mut state) } ) ;
4931
+ macro_rules! hash( ( $e: expr) => { $e. hash( & mut state) } ) ;
4934
4932
4935
- let region = |_hash : & mut sip:: SipState , r : Region | {
4933
+ let region = |_state : & mut sip:: SipState , r : Region | {
4936
4934
match r {
4937
4935
ReStatic => { }
4938
4936
@@ -4946,27 +4944,27 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
4946
4944
}
4947
4945
}
4948
4946
} ;
4949
- let vstore = |hash : & mut sip:: SipState , v : vstore | {
4947
+ let vstore = |state : & mut sip:: SipState , v : vstore | {
4950
4948
match v {
4951
- vstore_fixed( _) => 0u8 . hash ( hash ) ,
4952
- vstore_uniq => 1u8 . hash ( hash ) ,
4949
+ vstore_fixed( _) => 0u8 . hash ( state ) ,
4950
+ vstore_uniq => 1u8 . hash ( state ) ,
4953
4951
vstore_slice( r) => {
4954
- 2u8 . hash ( hash ) ;
4955
- region ( hash , r) ;
4952
+ 2u8 . hash ( state ) ;
4953
+ region ( state , r) ;
4956
4954
}
4957
4955
}
4958
4956
} ;
4959
- let did = |hash : & mut sip:: SipState , did : DefId | {
4957
+ let did = |state : & mut sip:: SipState , did : DefId | {
4960
4958
let h = if ast_util:: is_local ( did) {
4961
4959
local_hash. clone ( )
4962
4960
} else {
4963
4961
tcx. sess . cstore . get_crate_hash ( did. krate )
4964
4962
} ;
4965
- h. as_bytes ( ) . hash ( hash ) ;
4966
- did. node . hash ( hash ) ;
4963
+ h. as_bytes ( ) . hash ( state ) ;
4964
+ did. node . hash ( state ) ;
4967
4965
} ;
4968
- let mt = |hash : & mut sip:: SipState , mt : mt | {
4969
- mt. mutbl . hash ( hash ) ;
4966
+ let mt = |state : & mut sip:: SipState , mt : mt | {
4967
+ mt. mutbl . hash ( state ) ;
4970
4968
} ;
4971
4969
ty:: walk_ty ( t, |t| {
4972
4970
match ty:: get ( t) . sty {
@@ -5002,17 +5000,17 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
5002
5000
}
5003
5001
ty_vec( m, v) => {
5004
5002
byte ! ( 11 ) ;
5005
- mt ( & mut hash , m) ;
5006
- vstore ( & mut hash , v) ;
5003
+ mt ( & mut state , m) ;
5004
+ vstore ( & mut state , v) ;
5007
5005
}
5008
5006
ty_ptr( m) => {
5009
5007
byte ! ( 12 ) ;
5010
- mt ( & mut hash , m) ;
5008
+ mt ( & mut state , m) ;
5011
5009
}
5012
5010
ty_rptr( r, m) => {
5013
5011
byte ! ( 13 ) ;
5014
- region ( & mut hash , r) ;
5015
- mt ( & mut hash , m) ;
5012
+ region ( & mut state , r) ;
5013
+ mt ( & mut state , m) ;
5016
5014
}
5017
5015
ty_bare_fn( ref b) => {
5018
5016
byte ! ( 14 ) ;
@@ -5025,24 +5023,24 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
5025
5023
hash ! ( c. sigil) ;
5026
5024
hash ! ( c. onceness) ;
5027
5025
hash ! ( c. bounds) ;
5028
- region ( & mut hash , c. region ) ;
5026
+ region ( & mut state , c. region ) ;
5029
5027
}
5030
5028
ty_trait( d, _, store, m, bounds) => {
5031
5029
byte ! ( 17 ) ;
5032
- did ( & mut hash , d) ;
5030
+ did ( & mut state , d) ;
5033
5031
match store {
5034
5032
UniqTraitStore => byte ! ( 0 ) ,
5035
5033
RegionTraitStore ( r) => {
5036
5034
byte ! ( 1 )
5037
- region ( & mut hash , r) ;
5035
+ region ( & mut state , r) ;
5038
5036
}
5039
5037
}
5040
5038
hash ! ( m) ;
5041
5039
hash ! ( bounds) ;
5042
5040
}
5043
5041
ty_struct( d, _) => {
5044
5042
byte ! ( 18 ) ;
5045
- did ( & mut hash , d) ;
5043
+ did ( & mut state , d) ;
5046
5044
}
5047
5045
ty_tup( ref inner) => {
5048
5046
byte ! ( 19 ) ;
@@ -5051,22 +5049,22 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
5051
5049
ty_param( p) => {
5052
5050
byte ! ( 20 ) ;
5053
5051
hash ! ( p. idx) ;
5054
- did ( & mut hash , p. def_id ) ;
5052
+ did ( & mut state , p. def_id ) ;
5055
5053
}
5056
5054
ty_self( d) => {
5057
5055
byte ! ( 21 ) ;
5058
- did ( & mut hash , d) ;
5056
+ did ( & mut state , d) ;
5059
5057
}
5060
5058
ty_infer( _) => unreachable ! ( ) ,
5061
5059
ty_err => byte ! ( 23 ) ,
5062
5060
ty_unboxed_vec( m) => {
5063
5061
byte ! ( 24 ) ;
5064
- mt ( & mut hash , m) ;
5062
+ mt ( & mut state , m) ;
5065
5063
}
5066
5064
}
5067
5065
} ) ;
5068
5066
5069
- hash . result ( )
5067
+ state . result ( )
5070
5068
}
5071
5069
5072
5070
impl Variance {
0 commit comments