@@ -571,7 +571,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
571571 Failed ( err) => return Failed ( err) ,
572572 } ;
573573
574- let ( source , value_result, type_result) = match directive. subclass {
574+ let ( name , value_result, type_result) = match directive. subclass {
575575 SingleImport { source, ref value_result, ref type_result, .. } =>
576576 ( source, value_result. get ( ) , type_result. get ( ) ) ,
577577 GlobImport { .. } if module. def_id ( ) == directive. parent . def_id ( ) => {
@@ -584,34 +584,34 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
584584
585585 for & ( ns, result) in & [ ( ValueNS , value_result) , ( TypeNS , type_result) ] {
586586 if let Ok ( binding) = result {
587- self . record_use ( source , ns, binding) ;
587+ self . record_use ( name , ns, binding) ;
588588 }
589589 }
590590
591591 if value_result. is_err ( ) && type_result. is_err ( ) {
592592 let ( value_result, type_result) ;
593- value_result = self . resolve_name_in_module ( module, source , ValueNS , false , Some ( span) ) ;
594- type_result = self . resolve_name_in_module ( module, source , TypeNS , false , Some ( span) ) ;
593+ value_result = self . resolve_name_in_module ( module, name , ValueNS , false , Some ( span) ) ;
594+ type_result = self . resolve_name_in_module ( module, name , TypeNS , false , Some ( span) ) ;
595595
596596 return if let ( Failed ( _) , Failed ( _) ) = ( value_result, type_result) {
597597 let resolutions = module. resolutions . borrow ( ) ;
598- let names = resolutions. iter ( ) . filter_map ( |( & ( ref name , _) , resolution) | {
599- if * name == source { return None ; } // Never suggest the same name
598+ let names = resolutions. iter ( ) . filter_map ( |( & ( ref n , _) , resolution) | {
599+ if * n == name { return None ; } // Never suggest the same name
600600 match * resolution. borrow ( ) {
601- NameResolution { binding : Some ( _) , .. } => Some ( name ) ,
601+ NameResolution { binding : Some ( _) , .. } => Some ( n ) ,
602602 NameResolution { single_imports : SingleImports :: None , .. } => None ,
603- _ => Some ( name ) ,
603+ _ => Some ( n ) ,
604604 }
605605 } ) ;
606- let lev_suggestion = match find_best_match_for_name ( names, & source . as_str ( ) , None ) {
606+ let lev_suggestion = match find_best_match_for_name ( names, & name . as_str ( ) , None ) {
607607 Some ( name) => format ! ( ". Did you mean to use `{}`?" , name) ,
608608 None => "" . to_owned ( ) ,
609609 } ;
610610 let module_str = module_to_string ( module) ;
611611 let msg = if & module_str == "???" {
612- format ! ( "There is no `{}` in the crate root{}" , source , lev_suggestion)
612+ format ! ( "There is no `{}` in the crate root{}" , name , lev_suggestion)
613613 } else {
614- format ! ( "There is no `{}` in `{}`{}" , source , module_str, lev_suggestion)
614+ format ! ( "There is no `{}` in `{}`{}" , name , module_str, lev_suggestion)
615615 } ;
616616 Failed ( Some ( ( directive. span , msg) ) )
617617 } else {
@@ -623,9 +623,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
623623
624624 match ( value_result, type_result) {
625625 ( Ok ( binding) , _) if !binding. pseudo_vis ( ) . is_at_least ( directive. vis . get ( ) , self ) => {
626- let msg = format ! ( "`{}` is private, and cannot be reexported" , source ) ;
627- let note_msg = format ! ( "consider marking `{}` as `pub` in the imported module" ,
628- source ) ;
626+ let msg = format ! ( "`{}` is private, and cannot be reexported" , name ) ;
627+ let note_msg =
628+ format ! ( "consider marking `{}` as `pub` in the imported module" , name ) ;
629629 struct_span_err ! ( self . session, directive. span, E0364 , "{}" , & msg)
630630 . span_note ( directive. span , & note_msg)
631631 . emit ( ) ;
@@ -635,15 +635,14 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
635635 if binding. is_extern_crate ( ) {
636636 let msg = format ! ( "extern crate `{}` is private, and cannot be reexported \
637637 (error E0364), consider declaring with `pub`",
638- source ) ;
638+ name ) ;
639639 self . session . add_lint ( PRIVATE_IN_PUBLIC , directive. id , directive. span , msg) ;
640640 } else {
641- let mut err = struct_span_err ! ( self . session, directive. span, E0365 ,
642- "`{}` is private, and cannot be reexported" ,
643- source) ;
644- err. span_label ( directive. span , & format ! ( "reexport of private `{}`" , source) ) ;
645- err. note ( & format ! ( "consider declaring type or module `{}` with `pub`" , source) ) ;
646- err. emit ( ) ;
641+ struct_span_err ! ( self . session, directive. span, E0365 ,
642+ "`{}` is private, and cannot be reexported" , name)
643+ . span_label ( directive. span , & format ! ( "reexport of private `{}`" , name) )
644+ . note ( & format ! ( "consider declaring type or module `{}` with `pub`" , name) )
645+ . emit ( ) ;
647646 }
648647 }
649648
0 commit comments