@@ -332,92 +332,45 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
332
332
module_ : Module < ' b > ,
333
333
import_directive : & ImportDirective )
334
334
-> ResolveResult < ( ) > {
335
- let mut resolution_result = ResolveResult :: Failed ( None ) ;
336
- let module_path = & import_directive. module_path ;
337
-
338
335
debug ! ( "(resolving import for module) resolving import `{}::...` in `{}`" ,
339
- names_to_string( & module_path [ .. ] ) ,
336
+ names_to_string( & import_directive . module_path ) ,
340
337
module_to_string( & * module_) ) ;
341
338
342
- // First, resolve the module path for the directive, if necessary.
343
- let container = if module_path. is_empty ( ) {
344
- // Use the crate root.
345
- Some ( ( self . resolver . graph_root , LastMod ( AllPublic ) ) )
346
- } else {
347
- match self . resolver . resolve_module_path ( module_,
348
- & module_path[ ..] ,
349
- UseLexicalScopeFlag :: DontUseLexicalScope ,
350
- import_directive. span ) {
351
- ResolveResult :: Failed ( err) => {
352
- resolution_result = ResolveResult :: Failed ( err) ;
353
- None
354
- }
355
- ResolveResult :: Indeterminate => {
356
- resolution_result = ResolveResult :: Indeterminate ;
357
- None
358
- }
359
- ResolveResult :: Success ( container) => Some ( container) ,
360
- }
361
- } ;
362
-
363
- match container {
364
- None => { }
365
- Some ( ( containing_module, lp) ) => {
339
+ self . resolver
340
+ . resolve_module_path ( module_,
341
+ & import_directive. module_path ,
342
+ UseLexicalScopeFlag :: DontUseLexicalScope ,
343
+ import_directive. span )
344
+ . and_then ( |( containing_module, lp) | {
366
345
// We found the module that the target is contained
367
346
// within. Attempt to resolve the import within it.
368
-
369
- match import_directive. subclass {
370
- SingleImport ( target, source) => {
371
- resolution_result = self . resolve_single_import ( & module_,
372
- containing_module,
373
- target,
374
- source,
375
- import_directive,
376
- lp) ;
377
- }
378
- GlobImport => {
379
- resolution_result = self . resolve_glob_import ( & module_,
380
- containing_module,
381
- import_directive,
382
- lp) ;
383
- }
347
+ if let SingleImport ( target, source) = import_directive. subclass {
348
+ self . resolve_single_import ( & module_,
349
+ containing_module,
350
+ target,
351
+ source,
352
+ import_directive,
353
+ lp)
354
+ } else {
355
+ self . resolve_glob_import ( & module_, containing_module, import_directive, lp)
384
356
}
385
- }
386
- }
387
-
388
- // Decrement the count of unresolved imports.
389
- match resolution_result {
390
- ResolveResult :: Success ( ( ) ) => {
357
+ } )
358
+ . and_then ( |( ) | {
359
+ // Decrement the count of unresolved imports.
391
360
assert ! ( self . resolver. unresolved_imports >= 1 ) ;
392
361
self . resolver . unresolved_imports -= 1 ;
393
- }
394
- _ => {
395
- // Nothing to do here; just return the error.
396
- }
397
- }
398
362
399
- // Decrement the count of unresolved globs if necessary. But only if
400
- // the resolution result is a success -- other cases will
401
- // be handled by the main loop.
402
-
403
- if resolution_result. success ( ) {
404
- match import_directive. subclass {
405
- GlobImport => {
363
+ if let GlobImport = import_directive. subclass {
406
364
module_. dec_glob_count ( ) ;
407
365
if import_directive. is_public {
408
366
module_. dec_pub_glob_count ( ) ;
409
367
}
410
368
}
411
- SingleImport ( .. ) => {
412
- // Ignore.
369
+ if import_directive . is_public {
370
+ module_ . dec_pub_count ( ) ;
413
371
}
414
- }
415
- if import_directive. is_public {
416
- module_. dec_pub_count ( ) ;
417
- }
418
- }
419
-
420
- return resolution_result;
372
+ Success ( ( ) )
373
+ } )
421
374
}
422
375
423
376
/// Resolves the name in the namespace of the module because it is being imported by
0 commit comments