@@ -132,7 +132,11 @@ pub fn prepare_target<'a, 'cfg>(
132
132
/// * its package id
133
133
/// * its extern crate name
134
134
/// * its calculated fingerprint for the dependency
135
- type DepFingerprint = ( String , String , Arc < Fingerprint > ) ;
135
+ struct DepFingerprint {
136
+ pkg_id : String ,
137
+ name : String ,
138
+ fingerprint : Arc < Fingerprint > ,
139
+ }
136
140
137
141
/// A fingerprint can be considered to be a "short string" representing the
138
142
/// state of a world for a package.
@@ -162,10 +166,6 @@ pub struct Fingerprint {
162
166
target : u64 ,
163
167
profile : u64 ,
164
168
path : u64 ,
165
- #[ serde(
166
- serialize_with = "serialize_deps" ,
167
- deserialize_with = "deserialize_deps"
168
- ) ]
169
169
deps : Vec < DepFingerprint > ,
170
170
local : Vec < LocalFingerprint > ,
171
171
#[ serde( skip_serializing, skip_deserializing) ]
@@ -174,32 +174,31 @@ pub struct Fingerprint {
174
174
edition : Edition ,
175
175
}
176
176
177
- fn serialize_deps < S > ( deps : & [ DepFingerprint ] , ser : S ) -> Result < S :: Ok , S :: Error >
178
- where
179
- S : ser:: Serializer ,
180
- {
181
- ser. collect_seq ( deps. iter ( ) . map ( |& ( ref a, ref b, ref c) | ( a, b, c. hash ( ) ) ) )
177
+ impl Serialize for DepFingerprint {
178
+ fn serialize < S > ( & self , ser : S ) -> Result < S :: Ok , S :: Error >
179
+ where
180
+ S : ser:: Serializer ,
181
+ {
182
+ ( & self . pkg_id , & self . name , & self . fingerprint . hash ( ) ) . serialize ( ser)
183
+ }
182
184
}
183
185
184
- fn deserialize_deps < ' de , D > ( d : D ) -> Result < Vec < DepFingerprint > , D :: Error >
185
- where
186
- D : de:: Deserializer < ' de > ,
187
- {
188
- let decoded = <Vec < ( String , String , u64 ) > >:: deserialize ( d) ?;
189
- Ok ( decoded
190
- . into_iter ( )
191
- . map ( |( pkg_id, name, hash) | {
192
- (
193
- pkg_id,
194
- name,
195
- Arc :: new ( Fingerprint {
196
- local : vec ! [ LocalFingerprint :: Precalculated ( String :: new( ) ) ] ,
197
- memoized_hash : Mutex :: new ( Some ( hash) ) ,
198
- ..Fingerprint :: new ( )
199
- } ) ,
200
- )
186
+ impl < ' de > Deserialize < ' de > for DepFingerprint {
187
+ fn deserialize < D > ( d : D ) -> Result < DepFingerprint , D :: Error >
188
+ where
189
+ D : de:: Deserializer < ' de > ,
190
+ {
191
+ let ( pkg_id, name, hash) = <( String , String , u64 ) >:: deserialize ( d) ?;
192
+ Ok ( DepFingerprint {
193
+ pkg_id,
194
+ name,
195
+ fingerprint : Arc :: new ( Fingerprint {
196
+ local : vec ! [ LocalFingerprint :: Precalculated ( String :: new( ) ) ] ,
197
+ memoized_hash : Mutex :: new ( Some ( hash) ) ,
198
+ ..Fingerprint :: new ( )
199
+ } ) ,
201
200
} )
202
- . collect ( ) )
201
+ }
203
202
}
204
203
205
204
#[ derive( Serialize , Deserialize , Hash ) ]
@@ -352,8 +351,8 @@ impl Fingerprint {
352
351
failure:: bail!( "number of dependencies has changed" )
353
352
}
354
353
for ( a, b) in self . deps . iter ( ) . zip ( old. deps . iter ( ) ) {
355
- if a. 1 != b. 1 || a. 2 . hash ( ) != b. 2 . hash ( ) {
356
- failure:: bail!( "new ({}) != old ({})" , a. 0 , b. 0 )
354
+ if a. name != b. name || a. fingerprint . hash ( ) != b. fingerprint . hash ( ) {
355
+ failure:: bail!( "new ({}) != old ({})" , a. pkg_id , b. pkg_id )
357
356
}
358
357
}
359
358
Ok ( ( ) )
@@ -380,7 +379,12 @@ impl hash::Hash for Fingerprint {
380
379
. hash ( h) ;
381
380
382
381
h. write_usize ( deps. len ( ) ) ;
383
- for & ( ref pkg_id, ref name, ref fingerprint) in deps {
382
+ for DepFingerprint {
383
+ pkg_id,
384
+ name,
385
+ fingerprint,
386
+ } in deps
387
+ {
384
388
pkg_id. hash ( h) ;
385
389
name. hash ( h) ;
386
390
// use memoized dep hashes to avoid exponential blowup
@@ -455,7 +459,11 @@ fn calculate<'a, 'cfg>(
455
459
. map ( |dep| {
456
460
calculate ( cx, dep) . and_then ( |fingerprint| {
457
461
let name = cx. bcx . extern_crate_name ( unit, dep) ?;
458
- Ok ( ( dep. pkg . package_id ( ) . to_string ( ) , name, fingerprint) )
462
+ Ok ( DepFingerprint {
463
+ pkg_id : dep. pkg . package_id ( ) . to_string ( ) ,
464
+ name,
465
+ fingerprint,
466
+ } )
459
467
} )
460
468
} )
461
469
. collect :: < CargoResult < Vec < _ > > > ( ) ?;
@@ -470,7 +478,7 @@ fn calculate<'a, 'cfg>(
470
478
LocalFingerprint :: Precalculated ( fingerprint)
471
479
} ;
472
480
let mut deps = deps;
473
- deps. sort_by ( |& ( ref a, _ , _ ) , & ( ref b , _ , _ ) | a. cmp ( b ) ) ;
481
+ deps. sort_by ( |a, b | a. pkg_id . cmp ( & b . pkg_id ) ) ;
474
482
let extra_flags = if unit. mode . is_doc ( ) {
475
483
bcx. rustdocflags_args ( unit) ?
476
484
} else {
0 commit comments