@@ -235,6 +235,11 @@ pub fn dep(name: &str) -> Dependency {
235
235
pub fn dep_req ( name : & str , req : & str ) -> Dependency {
236
236
Dependency :: parse_no_deprecated ( name, Some ( req) , & registry_loc ( ) ) . unwrap ( )
237
237
}
238
+ pub fn dep_req_kind ( name : & str , req : & str , kind : Kind ) -> Dependency {
239
+ let mut dep = dep_req ( name, req) ;
240
+ dep. set_kind ( kind) ;
241
+ dep
242
+ }
238
243
239
244
pub fn dep_loc ( name : & str , location : & str ) -> Dependency {
240
245
let url = location. to_url ( ) . unwrap ( ) ;
@@ -277,12 +282,26 @@ impl fmt::Debug for PrettyPrintRegistry {
277
282
} else {
278
283
write ! ( f, "pkg!((\" {}\" , \" {}\" ) => [" , s. name( ) , s. version( ) ) ?;
279
284
for d in s. dependencies ( ) {
280
- write ! (
281
- f,
282
- "dep_req(\" {}\" , \" {}\" )," ,
283
- d. name_in_toml( ) ,
284
- d. version_req( )
285
- ) ?;
285
+ if d. kind ( ) == Kind :: Normal {
286
+ write ! (
287
+ f,
288
+ "dep_req(\" {}\" , \" {}\" )," ,
289
+ d. name_in_toml( ) ,
290
+ d. version_req( )
291
+ ) ?;
292
+ } else {
293
+ write ! (
294
+ f,
295
+ "dep_req_kind(\" {}\" , \" {}\" , {})," ,
296
+ d. name_in_toml( ) ,
297
+ d. version_req( ) ,
298
+ match d. kind( ) {
299
+ Kind :: Development => "Kind::Development" ,
300
+ Kind :: Build => "Kind::Build" ,
301
+ Kind :: Normal => "Kind::Normal" ,
302
+ }
303
+ ) ?;
304
+ }
286
305
}
287
306
write ! ( f, "])," ) ?;
288
307
}
@@ -304,6 +323,8 @@ fn meta_test_deep_pretty_print_registry() {
304
323
pkg!( ( "bar" , "2.0.0" ) => [ dep_req( "baz" , "=1.0.1" ) ] ) ,
305
324
pkg!( ( "baz" , "1.0.2" ) => [ dep_req( "other" , "2" ) ] ) ,
306
325
pkg!( ( "baz" , "1.0.1" ) ) ,
326
+ pkg!( ( "cat" , "1.0.2" ) => [ dep_req_kind( "other" , "2" , Kind :: Build ) ] ) ,
327
+ pkg!( ( "cat" , "1.0.2" ) => [ dep_req_kind( "other" , "2" , Kind :: Development ) ] ) ,
307
328
pkg!( ( "dep_req" , "1.0.0" ) ) ,
308
329
pkg!( ( "dep_req" , "2.0.0" ) ) ,
309
330
] )
@@ -313,7 +334,10 @@ fn meta_test_deep_pretty_print_registry() {
313
334
pkg!((\" bar\" , \" 1.0.0\" ) => [dep_req(\" baz\" , \" = 1.0.2\" ),dep_req(\" other\" , \" ^1\" ),]),\
314
335
pkg!((\" bar\" , \" 2.0.0\" ) => [dep_req(\" baz\" , \" = 1.0.1\" ),]),\
315
336
pkg!((\" baz\" , \" 1.0.2\" ) => [dep_req(\" other\" , \" ^2\" ),]),\
316
- pkg!((\" baz\" , \" 1.0.1\" )),pkg!((\" dep_req\" , \" 1.0.0\" )),\
337
+ pkg!((\" baz\" , \" 1.0.1\" )),\
338
+ pkg!((\" cat\" , \" 1.0.2\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Build),]),\
339
+ pkg!((\" cat\" , \" 1.0.2\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Development),]),\
340
+ pkg!((\" dep_req\" , \" 1.0.0\" )),\
317
341
pkg!((\" dep_req\" , \" 2.0.0\" )),]"
318
342
)
319
343
}
@@ -357,7 +381,7 @@ pub fn registry_strategy(
357
381
let max_deps = max_versions * ( max_crates * ( max_crates - 1 ) ) / shrinkage;
358
382
359
383
let raw_version_range = ( any :: < Index > ( ) , any :: < Index > ( ) ) ;
360
- let raw_dependency = ( any :: < Index > ( ) , any :: < Index > ( ) , raw_version_range) ;
384
+ let raw_dependency = ( any :: < Index > ( ) , any :: < Index > ( ) , raw_version_range, 0 ..= 1 ) ;
361
385
362
386
fn order_index ( a : Index , b : Index , size : usize ) -> ( usize , usize ) {
363
387
let ( a, b) = ( a. index ( size) , b. index ( size) ) ;
@@ -374,7 +398,7 @@ pub fn registry_strategy(
374
398
. collect ( ) ;
375
399
let len_all_pkgid = list_of_pkgid. len ( ) ;
376
400
let mut dependency_by_pkgid = vec ! [ vec![ ] ; len_all_pkgid] ;
377
- for ( a, b, ( c, d) ) in raw_dependencies {
401
+ for ( a, b, ( c, d) , k ) in raw_dependencies {
378
402
let ( a, b) = order_index ( a, b, len_all_pkgid) ;
379
403
let ( ( dep_name, _) , _) = list_of_pkgid[ a] ;
380
404
if ( list_of_pkgid[ b] . 0 ) . 0 == dep_name {
@@ -383,13 +407,19 @@ pub fn registry_strategy(
383
407
let s = & crate_vers_by_name[ dep_name] ;
384
408
let ( c, d) = order_index ( c, d, s. len ( ) ) ;
385
409
386
- dependency_by_pkgid[ b] . push ( dep_req (
410
+ dependency_by_pkgid[ b] . push ( dep_req_kind (
387
411
& dep_name,
388
412
& if c == d {
389
413
format ! ( "={}" , s[ c] . 0 )
390
414
} else {
391
415
format ! ( ">={}, <={}" , s[ c] . 0 , s[ d] . 0 )
392
416
} ,
417
+ match k {
418
+ 0 => Kind :: Normal ,
419
+ 1 => Kind :: Build ,
420
+ // => Kind::Development,
421
+ _ => panic ! ( "bad index for Kind" ) ,
422
+ } ,
393
423
) )
394
424
}
395
425
0 commit comments