@@ -250,9 +250,10 @@ pub fn dep(name: &str) -> Dependency {
250
250
pub fn dep_req ( name : & str , req : & str ) -> Dependency {
251
251
Dependency :: parse_no_deprecated ( name, Some ( req) , registry_loc ( ) ) . unwrap ( )
252
252
}
253
- pub fn dep_req_kind ( name : & str , req : & str , kind : Kind ) -> Dependency {
253
+ pub fn dep_req_kind ( name : & str , req : & str , kind : Kind , public : bool ) -> Dependency {
254
254
let mut dep = dep_req ( name, req) ;
255
255
dep. set_kind ( kind) ;
256
+ dep. set_public ( public) ;
256
257
dep
257
258
}
258
259
@@ -297,9 +298,12 @@ impl fmt::Debug for PrettyPrintRegistry {
297
298
} else {
298
299
write ! ( f, "pkg!((\" {}\" , \" {}\" ) => [" , s. name( ) , s. version( ) ) ?;
299
300
for d in s. dependencies ( ) {
300
- if d. kind ( ) == Kind :: Normal && & d. version_req ( ) . to_string ( ) == "*" {
301
+ if d. kind ( ) == Kind :: Normal
302
+ && & d. version_req ( ) . to_string ( ) == "*"
303
+ && !d. is_public ( )
304
+ {
301
305
write ! ( f, "dep(\" {}\" )," , d. name_in_toml( ) ) ?;
302
- } else if d. kind ( ) == Kind :: Normal {
306
+ } else if d. kind ( ) == Kind :: Normal && !d . is_public ( ) {
303
307
write ! (
304
308
f,
305
309
"dep_req(\" {}\" , \" {}\" )," ,
@@ -309,14 +313,15 @@ impl fmt::Debug for PrettyPrintRegistry {
309
313
} else {
310
314
write ! (
311
315
f,
312
- "dep_req_kind(\" {}\" , \" {}\" , {})," ,
316
+ "dep_req_kind(\" {}\" , \" {}\" , {}, {} )," ,
313
317
d. name_in_toml( ) ,
314
318
d. version_req( ) ,
315
319
match d. kind( ) {
316
320
Kind :: Development => "Kind::Development" ,
317
321
Kind :: Build => "Kind::Build" ,
318
322
Kind :: Normal => "Kind::Normal" ,
319
- }
323
+ } ,
324
+ d. is_public( )
320
325
) ?;
321
326
}
322
327
}
@@ -341,8 +346,10 @@ fn meta_test_deep_pretty_print_registry() {
341
346
pkg!( ( "bar" , "2.0.0" ) => [ dep_req( "baz" , "=1.0.1" ) ] ) ,
342
347
pkg!( ( "baz" , "1.0.2" ) => [ dep_req( "other" , "2" ) ] ) ,
343
348
pkg!( ( "baz" , "1.0.1" ) ) ,
344
- pkg!( ( "cat" , "1.0.2" ) => [ dep_req_kind( "other" , "2" , Kind :: Build ) ] ) ,
345
- pkg!( ( "cat" , "1.0.2" ) => [ dep_req_kind( "other" , "2" , Kind :: Development ) ] ) ,
349
+ pkg!( ( "cat" , "1.0.2" ) => [ dep_req_kind( "other" , "2" , Kind :: Build , false ) ] ) ,
350
+ pkg!( ( "cat" , "1.0.3" ) => [ dep_req_kind( "other" , "2" , Kind :: Development , false ) ] ) ,
351
+ pkg!( ( "cat" , "1.0.4" ) => [ dep_req_kind( "other" , "2" , Kind :: Build , true ) ] ) ,
352
+ pkg!( ( "cat" , "1.0.5" ) => [ dep_req_kind( "other" , "2" , Kind :: Development , true ) ] ) ,
346
353
pkg!( ( "dep_req" , "1.0.0" ) ) ,
347
354
pkg!( ( "dep_req" , "2.0.0" ) ) ,
348
355
] )
@@ -354,8 +361,10 @@ fn meta_test_deep_pretty_print_registry() {
354
361
pkg!((\" bar\" , \" 2.0.0\" ) => [dep_req(\" baz\" , \" = 1.0.1\" ),]),\
355
362
pkg!((\" baz\" , \" 1.0.2\" ) => [dep_req(\" other\" , \" ^2\" ),]),\
356
363
pkg!((\" baz\" , \" 1.0.1\" )),\
357
- pkg!((\" cat\" , \" 1.0.2\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Build),]),\
358
- pkg!((\" cat\" , \" 1.0.2\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Development),]),\
364
+ pkg!((\" cat\" , \" 1.0.2\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Build, false),]),\
365
+ pkg!((\" cat\" , \" 1.0.3\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Development, false),]),\
366
+ pkg!((\" cat\" , \" 1.0.4\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Build, true),]),\
367
+ pkg!((\" cat\" , \" 1.0.5\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Development, true),]),\
359
368
pkg!((\" dep_req\" , \" 1.0.0\" )),\
360
369
pkg!((\" dep_req\" , \" 2.0.0\" )),]"
361
370
)
@@ -405,7 +414,13 @@ pub fn registry_strategy(
405
414
let max_deps = max_versions * ( max_crates * ( max_crates - 1 ) ) / shrinkage;
406
415
407
416
let raw_version_range = ( any :: < Index > ( ) , any :: < Index > ( ) ) ;
408
- let raw_dependency = ( any :: < Index > ( ) , any :: < Index > ( ) , raw_version_range, 0 ..=1 ) ;
417
+ let raw_dependency = (
418
+ any :: < Index > ( ) ,
419
+ any :: < Index > ( ) ,
420
+ raw_version_range,
421
+ 0 ..=1 ,
422
+ any :: < bool > ( ) ,
423
+ ) ;
409
424
410
425
fn order_index ( a : Index , b : Index , size : usize ) -> ( usize , usize ) {
411
426
let ( a, b) = ( a. index ( size) , b. index ( size) ) ;
@@ -432,7 +447,7 @@ pub fn registry_strategy(
432
447
. collect ( ) ;
433
448
let len_all_pkgid = list_of_pkgid. len ( ) ;
434
449
let mut dependency_by_pkgid = vec ! [ vec![ ] ; len_all_pkgid] ;
435
- for ( a, b, ( c, d) , k) in raw_dependencies {
450
+ for ( a, b, ( c, d) , k, p ) in raw_dependencies {
436
451
let ( a, b) = order_index ( a, b, len_all_pkgid) ;
437
452
let ( a, b) = if reverse_alphabetical { ( b, a) } else { ( a, b) } ;
438
453
let ( ( dep_name, _) , _) = list_of_pkgid[ a] ;
@@ -443,27 +458,28 @@ pub fn registry_strategy(
443
458
let s_last_index = s. len ( ) - 1 ;
444
459
let ( c, d) = order_index ( c, d, s. len ( ) ) ;
445
460
446
- dependency_by_pkgid[ b] . push ( dep_req_kind (
447
- & dep_name,
448
- & if c == 0 && d == s_last_index {
449
- "*" . to_string ( )
450
- } else if c == 0 {
451
- format ! ( "<={}" , s[ d] . 0 )
452
- } else if d == s_last_index {
453
- format ! ( ">={}" , s[ c] . 0 )
454
- } else if c == d {
455
- format ! ( "={}" , s[ c] . 0 )
456
- } else {
457
- format ! ( ">={}, <={}" , s[ c] . 0 , s[ d] . 0 )
458
- } ,
459
- match k {
460
- 0 => Kind :: Normal ,
461
- 1 => Kind :: Build ,
462
- // => Kind::Development, // Development has not impact so don't gen
463
- _ => panic ! ( "bad index for Kind" ) ,
464
- } ,
465
- ) )
466
- }
461
+ dependency_by_pkgid[ b] . push ( dep_req_kind (
462
+ & dep_name,
463
+ & if c == 0 && d == s_last_index {
464
+ "*" . to_string ( )
465
+ } else if c == 0 {
466
+ format ! ( "<={}" , s[ d] . 0 )
467
+ } else if d == s_last_index {
468
+ format ! ( ">={}" , s[ c] . 0 )
469
+ } else if c == d {
470
+ format ! ( "={}" , s[ c] . 0 )
471
+ } else {
472
+ format ! ( ">={}, <={}" , s[ c] . 0 , s[ d] . 0 )
473
+ } ,
474
+ match k {
475
+ 0 => Kind :: Normal ,
476
+ 1 => Kind :: Build ,
477
+ // => Kind::Development, // Development has not impact so don't gen
478
+ _ => panic ! ( "bad index for Kind" ) ,
479
+ } ,
480
+ p,
481
+ ) )
482
+ }
467
483
468
484
PrettyPrintRegistry (
469
485
list_of_pkgid
0 commit comments