@@ -73,16 +73,20 @@ pub fn resolve_with_config_raw(
73
73
registry : & [ Summary ] ,
74
74
config : Option < & Config > ,
75
75
) -> CargoResult < Resolve > {
76
- struct MyRegistry < ' a > ( & ' a [ Summary ] ) ;
76
+ struct MyRegistry < ' a > {
77
+ list : & ' a [ Summary ] ,
78
+ used : HashSet < PackageId > ,
79
+ } ;
77
80
impl < ' a > Registry for MyRegistry < ' a > {
78
81
fn query (
79
82
& mut self ,
80
83
dep : & Dependency ,
81
84
f : & mut dyn FnMut ( Summary ) ,
82
85
fuzzy : bool ,
83
86
) -> CargoResult < ( ) > {
84
- for summary in self . 0 . iter ( ) {
87
+ for summary in self . list . iter ( ) {
85
88
if fuzzy || dep. matches ( summary) {
89
+ self . used . insert ( summary. package_id ( ) ) ;
86
90
f ( summary. clone ( ) ) ;
87
91
}
88
92
}
@@ -97,7 +101,28 @@ pub fn resolve_with_config_raw(
97
101
false
98
102
}
99
103
}
100
- let mut registry = MyRegistry ( registry) ;
104
+ impl < ' a > Drop for MyRegistry < ' a > {
105
+ fn drop ( & mut self ) {
106
+ if std:: thread:: panicking ( ) && self . list . len ( ) != self . used . len ( ) {
107
+ // we found a case that causes a panic and did not use all of the input.
108
+ // lets print the part of the input that was used for minimization.
109
+ println ! (
110
+ "{:?}" ,
111
+ PrettyPrintRegistry (
112
+ self . list
113
+ . iter( )
114
+ . filter( |s| { self . used. contains( & s. package_id( ) ) } )
115
+ . cloned( )
116
+ . collect( )
117
+ )
118
+ ) ;
119
+ }
120
+ }
121
+ }
122
+ let mut registry = MyRegistry {
123
+ list : registry,
124
+ used : HashSet :: new ( ) ,
125
+ } ;
101
126
let summary = Summary :: new (
102
127
pkg,
103
128
deps,
@@ -348,8 +373,6 @@ fn meta_test_deep_pretty_print_registry() {
348
373
pkg!( ( "baz" , "1.0.1" ) ) ,
349
374
pkg!( ( "cat" , "1.0.2" ) => [ dep_req_kind( "other" , "2" , Kind :: Build , false ) ] ) ,
350
375
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 , false ) ] ) ,
352
- pkg!( ( "cat" , "1.0.5" ) => [ dep_req_kind( "other" , "2" , Kind :: Development , false ) ] ) ,
353
376
pkg!( ( "dep_req" , "1.0.0" ) ) ,
354
377
pkg!( ( "dep_req" , "2.0.0" ) ) ,
355
378
] )
@@ -363,8 +386,6 @@ fn meta_test_deep_pretty_print_registry() {
363
386
pkg!((\" baz\" , \" 1.0.1\" )),\
364
387
pkg!((\" cat\" , \" 1.0.2\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Build, false),]),\
365
388
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, false),]),\
367
- pkg!((\" cat\" , \" 1.0.5\" ) => [dep_req_kind(\" other\" , \" ^2\" , Kind::Development, false),]),\
368
389
pkg!((\" dep_req\" , \" 1.0.0\" )),\
369
390
pkg!((\" dep_req\" , \" 2.0.0\" )),]"
370
391
)
0 commit comments