File tree 1 file changed +10
-4
lines changed
src/librustc_data_structures
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -132,8 +132,11 @@ impl<W> Hasher for StableHasher<W> {
132
132
133
133
#[ inline]
134
134
fn write_usize ( & mut self , i : usize ) {
135
- self . state . write_usize ( i. to_le ( ) ) ;
136
- self . bytes_hashed += :: std:: mem:: size_of :: < usize > ( ) as u64 ;
135
+ // Always treat usize as u64 so we get the same results on 32 and 64 bit
136
+ // platforms. This is important for symbol hashes when cross compiling,
137
+ // for example.
138
+ self . state . write_u64 ( ( i as u64 ) . to_le ( ) ) ;
139
+ self . bytes_hashed += 8 ;
137
140
}
138
141
139
142
#[ inline]
@@ -168,8 +171,11 @@ impl<W> Hasher for StableHasher<W> {
168
171
169
172
#[ inline]
170
173
fn write_isize ( & mut self , i : isize ) {
171
- self . state . write_isize ( i. to_le ( ) ) ;
172
- self . bytes_hashed += :: std:: mem:: size_of :: < isize > ( ) as u64 ;
174
+ // Always treat isize as i64 so we get the same results on 32 and 64 bit
175
+ // platforms. This is important for symbol hashes when cross compiling,
176
+ // for example.
177
+ self . state . write_i64 ( ( i as i64 ) . to_le ( ) ) ;
178
+ self . bytes_hashed += 8 ;
173
179
}
174
180
}
175
181
You can’t perform that action at this time.
0 commit comments