@@ -371,14 +371,13 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
371371 }
372372
373373 /// Resolves the name in the namespace of the module because it is being imported by
374- /// importing_module. Returns the name bindings defining the name
375- /// and whether or not the name was imported.
374+ /// importing_module. Returns the name bindings defining the name.
376375 fn resolve_name_in_module ( & mut self ,
377376 module : Module < ' b > , // Module containing the name
378377 name : Name ,
379378 ns : Namespace ,
380379 importing_module : Module < ' b > ) // Module importing the name
381- -> ( ResolveResult < & ' b NameBinding < ' b > > , bool ) {
380+ -> ResolveResult < & ' b NameBinding < ' b > > {
382381 build_reduced_graph:: populate_module_if_necessary ( self . resolver , module) ;
383382 if let Some ( name_binding) = module. get_child ( name, ns) {
384383 if name_binding. is_extern_crate ( ) {
@@ -387,32 +386,32 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
387386 self . resolver . used_crates . insert ( krate) ;
388387 }
389388 }
390- return ( Success ( name_binding) , false )
389+ return Success ( name_binding) ;
391390 }
392391
393392 // If there is an unresolved glob at this point in the containing module, bail out.
394393 // We don't know enough to be able to resolve the name.
395394 if module. pub_glob_count . get ( ) > 0 {
396- return ( Indeterminate , false ) ;
395+ return Indeterminate ;
397396 }
398397
399398 match module. import_resolutions . borrow ( ) . get ( & ( name, ns) ) {
400399 // The containing module definitely doesn't have an exported import with the
401400 // name in question. We can therefore accurately report that names are unbound.
402- None => ( Failed ( None ) , false ) ,
401+ None => Failed ( None ) ,
403402
404403 // The name is an import which has been fully resolved, so we just follow it.
405404 Some ( resolution) if resolution. outstanding_references == 0 => {
406405 // Import resolutions must be declared with "pub" in order to be exported.
407406 if !resolution. is_public {
408- return ( Failed ( None ) , false ) ;
407+ return Failed ( None ) ;
409408 }
410409
411410 if let Some ( binding) = resolution. binding {
412411 self . resolver . record_import_use ( name, ns, & resolution) ;
413- ( Success ( binding) , true )
412+ Success ( binding)
414413 } else {
415- ( Failed ( None ) , false )
414+ Failed ( None )
416415 }
417416 }
418417
@@ -427,8 +426,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
427426 // In this case we continue as if we resolved the import and let
428427 // check_for_conflicts_between_imports_and_items handle the conflict
429428 Some ( _) => match ( importing_module. def_id ( ) , module. def_id ( ) ) {
430- ( Some ( id1) , Some ( id2) ) if id1 == id2 => ( Failed ( None ) , false ) ,
431- _ => ( Indeterminate , false )
429+ ( Some ( id1) , Some ( id2) ) if id1 == id2 => Failed ( None ) ,
430+ _ => Indeterminate
432431 } ,
433432 }
434433 }
@@ -460,13 +459,13 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
460459 } ;
461460
462461 // We need to resolve both namespaces for this to succeed.
463- let ( value_result, value_used_reexport ) =
462+ let value_result =
464463 self . resolve_name_in_module ( target_module, source, ValueNS , module_) ;
465- let ( type_result, type_used_reexport ) =
464+ let type_result =
466465 self . resolve_name_in_module ( target_module, source, TypeNS , module_) ;
467466
468467 match ( & value_result, & type_result) {
469- ( & Success ( name_binding) , _) if !value_used_reexport &&
468+ ( & Success ( name_binding) , _) if !name_binding . is_import ( ) &&
470469 directive. is_public &&
471470 !name_binding. is_public ( ) => {
472471 let msg = format ! ( "`{}` is private, and cannot be reexported" , source) ;
@@ -477,7 +476,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
477476 . emit ( ) ;
478477 }
479478
480- ( _, & Success ( name_binding) ) if !type_used_reexport && directive. is_public => {
479+ ( _, & Success ( name_binding) ) if !name_binding . is_import ( ) && directive. is_public => {
481480 if !name_binding. is_public ( ) {
482481 let msg = format ! ( "`{}` is private, and cannot be reexported" , source) ;
483482 let note_msg =
@@ -521,14 +520,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
521520 _ => ( ) ,
522521 }
523522
524- let mut value_used_public = false ;
525- let mut type_used_public = false ;
526-
527523 // We've successfully resolved the import. Write the results in.
528524 let mut import_resolutions = module_. import_resolutions . borrow_mut ( ) ;
529525
530526 {
531- let mut check_and_write_import = |namespace, result, used_public : & mut bool | {
527+ let mut check_and_write_import = |namespace, result| {
532528 let result: & ResolveResult < & NameBinding > = result;
533529
534530 let import_resolution = import_resolutions. get_mut ( & ( target, namespace) ) . unwrap ( ) ;
@@ -557,7 +553,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
557553 import_resolution. is_public = directive. is_public ;
558554
559555 self . add_export ( module_, target, & import_resolution) ;
560- * used_public = name_binding. is_public ( ) ;
561556 }
562557 Failed ( _) => {
563558 // Continue.
@@ -572,8 +567,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
572567 directive. span ,
573568 ( target, namespace) ) ;
574569 } ;
575- check_and_write_import ( ValueNS , & value_result, & mut value_used_public ) ;
576- check_and_write_import ( TypeNS , & type_result, & mut type_used_public ) ;
570+ check_and_write_import ( ValueNS , & value_result) ;
571+ check_and_write_import ( TypeNS , & type_result) ;
577572 }
578573
579574 if let ( & Failed ( _) , & Failed ( _) ) = ( & value_result, & type_result) {
@@ -583,9 +578,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
583578 return Failed ( Some ( ( directive. span , msg) ) ) ;
584579 }
585580
586- let value_used_public = value_used_reexport || value_used_public;
587- let type_used_public = type_used_reexport || type_used_public;
588-
589581 let value_def_and_priv = {
590582 let import_resolution_value = import_resolutions. get_mut ( & ( target, ValueNS ) ) . unwrap ( ) ;
591583 assert ! ( import_resolution_value. outstanding_references >= 1 ) ;
@@ -596,7 +588,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
596588 // purposes it's good enough to just favor one over the other.
597589 import_resolution_value. binding . as_ref ( ) . map ( |binding| {
598590 let def = binding. def ( ) . unwrap ( ) ;
599- let last_private = if value_used_public { lp } else { DependsOn ( def. def_id ( ) ) } ;
591+ let last_private = if binding . is_public ( ) { lp } else { DependsOn ( def. def_id ( ) ) } ;
600592 ( def, last_private)
601593 } )
602594 } ;
@@ -608,7 +600,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
608600
609601 import_resolution_type. binding . as_ref ( ) . map ( |binding| {
610602 let def = binding. def ( ) . unwrap ( ) ;
611- let last_private = if type_used_public { lp } else { DependsOn ( def. def_id ( ) ) } ;
603+ let last_private = if binding . is_public ( ) { lp } else { DependsOn ( def. def_id ( ) ) } ;
612604 ( def, last_private)
613605 } )
614606 } ;
0 commit comments