@@ -195,53 +195,61 @@ impl<'a> Context<'a> {
195
195
// of the crate id (path/name/id).
196
196
//
197
197
// The goal of this step is to look at as little metadata as possible.
198
- self . filesearch . search ( |path| {
199
- let file = match path. filename_str ( ) {
200
- None => return FileDoesntMatch ,
201
- Some ( file) => file,
202
- } ;
203
- if file. starts_with ( rlib_prefix. as_slice ( ) ) &&
204
- file. ends_with ( ".rlib" ) {
205
- info ! ( "rlib candidate: {}" , path. display( ) ) ;
206
- match self . try_match ( file, rlib_prefix. as_slice ( ) , ".rlib" ) {
207
- Some ( hash) => {
208
- info ! ( "rlib accepted, hash: {}" , hash) ;
209
- let slot = candidates. find_or_insert_with ( hash, |_| {
210
- ( HashSet :: new ( ) , HashSet :: new ( ) )
211
- } ) ;
212
- let ( ref mut rlibs, _) = * slot;
213
- rlibs. insert ( fs:: realpath ( path) . unwrap ( ) ) ;
214
- FileMatches
215
- }
216
- None => {
217
- info ! ( "rlib rejected" ) ;
218
- FileDoesntMatch
219
- }
220
- }
221
- } else if file. starts_with ( dylib_prefix. as_slice ( ) ) &&
222
- file. ends_with ( dysuffix) {
223
- info ! ( "dylib candidate: {}" , path. display( ) ) ;
224
- match self . try_match ( file,
225
- dylib_prefix. as_slice ( ) ,
226
- dysuffix) {
227
- Some ( hash) => {
228
- info ! ( "dylib accepted, hash: {}" , hash) ;
229
- let slot = candidates. find_or_insert_with ( hash, |_| {
230
- ( HashSet :: new ( ) , HashSet :: new ( ) )
231
- } ) ;
232
- let ( _, ref mut dylibs) = * slot;
233
- dylibs. insert ( fs:: realpath ( path) . unwrap ( ) ) ;
234
- FileMatches
198
+ {
199
+ let filesearch = self . filesearch . clone ( ) ;
200
+ let candidates_ptr = & mut candidates;
201
+ filesearch. search ( |path| {
202
+ let file = match path. filename_str ( ) {
203
+ None => return FileDoesntMatch ,
204
+ Some ( file) => file,
205
+ } ;
206
+ if file. starts_with ( rlib_prefix. as_slice ( ) ) &&
207
+ file. ends_with ( ".rlib" ) {
208
+ info ! ( "rlib candidate: {}" , path. display( ) ) ;
209
+ match self . try_match ( file,
210
+ rlib_prefix. as_slice ( ) ,
211
+ ".rlib" ) {
212
+ Some ( hash) => {
213
+ info ! ( "rlib accepted, hash: {}" , hash) ;
214
+ let slot =
215
+ candidates_ptr. find_or_insert_with ( hash, |_| {
216
+ ( HashSet :: new ( ) , HashSet :: new ( ) )
217
+ } ) ;
218
+ let ( ref mut rlibs, _) = * slot;
219
+ rlibs. insert ( fs:: realpath ( path) . unwrap ( ) ) ;
220
+ FileMatches
221
+ }
222
+ None => {
223
+ info ! ( "rlib rejected" ) ;
224
+ FileDoesntMatch
225
+ }
235
226
}
236
- None => {
237
- info ! ( "dylib rejected" ) ;
238
- FileDoesntMatch
227
+ } else if file. starts_with ( dylib_prefix. as_slice ( ) ) &&
228
+ file. ends_with ( dysuffix) {
229
+ info ! ( "dylib candidate: {}" , path. display( ) ) ;
230
+ match self . try_match ( file,
231
+ dylib_prefix. as_slice ( ) ,
232
+ dysuffix) {
233
+ Some ( hash) => {
234
+ info ! ( "dylib accepted, hash: {}" , hash) ;
235
+ let slot =
236
+ candidates_ptr. find_or_insert_with ( hash, |_| {
237
+ ( HashSet :: new ( ) , HashSet :: new ( ) )
238
+ } ) ;
239
+ let ( _, ref mut dylibs) = * slot;
240
+ dylibs. insert ( fs:: realpath ( path) . unwrap ( ) ) ;
241
+ FileMatches
242
+ }
243
+ None => {
244
+ info ! ( "dylib rejected" ) ;
245
+ FileDoesntMatch
246
+ }
239
247
}
248
+ } else {
249
+ FileDoesntMatch
240
250
}
241
- } else {
242
- FileDoesntMatch
243
- }
244
- } ) ;
251
+ } ) ;
252
+ }
245
253
246
254
// We have now collected all known libraries into a set of candidates
247
255
// keyed of the filename hash listed. For each filename, we also have a
0 commit comments