@@ -492,6 +492,10 @@ impl<'a> Resolver<'a> {
492492 // Go through all the scopes and try to resolve the name.
493493 let break_result = self . visit_scopes ( scope_set, parent_scope, orig_ident,
494494 |this, scope, use_prelude, ident| {
495+ let ok = |res, span, arenas| Ok ( (
496+ ( res, ty:: Visibility :: Public , span, ExpnId :: root ( ) ) . to_name_binding ( arenas) ,
497+ Flags :: empty ( ) ,
498+ ) ) ;
495499 let result = match scope {
496500 Scope :: DeriveHelpers => {
497501 let mut result = Err ( Determinacy :: Determined ) ;
@@ -500,10 +504,8 @@ impl<'a> Resolver<'a> {
500504 match this. resolve_macro_path ( derive, Some ( MacroKind :: Derive ) ,
501505 parent_scope, true , force) {
502506 Ok ( ( Some ( ext) , _) ) => if ext. helper_attrs . contains ( & ident. name ) {
503- let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ,
504- ty:: Visibility :: Public , derive. span , ExpnId :: root ( ) )
505- . to_name_binding ( this. arenas ) ;
506- result = Ok ( ( binding, Flags :: empty ( ) ) ) ;
507+ let res = Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ;
508+ result = ok ( res, derive. span , this. arenas ) ;
507509 break ;
508510 }
509511 Ok ( _) | Err ( Determinacy :: Determined ) => { }
@@ -571,12 +573,9 @@ impl<'a> Resolver<'a> {
571573 }
572574 }
573575 Scope :: RegisteredAttrs => match this. registered_attrs . get ( & ident) . cloned ( ) {
574- Some ( ident) => {
575- let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: Registered ) ,
576- ty:: Visibility :: Public , ident. span , ExpnId :: root ( ) )
577- . to_name_binding ( this. arenas ) ;
578- Ok ( ( binding, Flags :: empty ( ) ) )
579- }
576+ Some ( ident) => ok (
577+ Res :: NonMacroAttr ( NonMacroAttrKind :: Registered ) , ident. span , this. arenas
578+ ) ,
580579 None => Err ( Determinacy :: Determined )
581580 }
582581 Scope :: MacroUsePrelude => match this. macro_use_prelude . get ( & ident. name ) . cloned ( ) {
@@ -586,19 +585,14 @@ impl<'a> Resolver<'a> {
586585 ) )
587586 }
588587 Scope :: BuiltinAttrs => if is_builtin_attr_name ( ident. name ) {
589- let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: Builtin ) ,
590- ty:: Visibility :: Public , DUMMY_SP , ExpnId :: root ( ) )
591- . to_name_binding ( this. arenas ) ;
592- Ok ( ( binding, Flags :: empty ( ) ) )
588+ ok ( Res :: NonMacroAttr ( NonMacroAttrKind :: Builtin ) , DUMMY_SP , this. arenas )
593589 } else {
594590 Err ( Determinacy :: Determined )
595591 }
596592 Scope :: LegacyPluginHelpers => if this. session . plugin_attributes . borrow ( ) . iter ( )
597593 . any ( |( name, _) | ident. name == * name) {
598- let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: LegacyPluginHelper ) ,
599- ty:: Visibility :: Public , DUMMY_SP , ExpnId :: root ( ) )
600- . to_name_binding ( this. arenas ) ;
601- Ok ( ( binding, Flags :: empty ( ) ) )
594+ let res = Res :: NonMacroAttr ( NonMacroAttrKind :: LegacyPluginHelper ) ;
595+ ok ( res, DUMMY_SP , this. arenas )
602596 } else {
603597 Err ( Determinacy :: Determined )
604598 }
@@ -609,12 +603,7 @@ impl<'a> Resolver<'a> {
609603 ) ) ,
610604 }
611605 Scope :: ToolPrelude => match this. registered_tools . get ( & ident) . cloned ( ) {
612- Some ( ident) => {
613- let binding = ( Res :: ToolMod ,
614- ty:: Visibility :: Public , ident. span , ExpnId :: root ( ) )
615- . to_name_binding ( this. arenas ) ;
616- Ok ( ( binding, Flags :: empty ( ) ) )
617- }
606+ Some ( ident) => ok ( Res :: ToolMod , ident. span , this. arenas ) ,
618607 None => Err ( Determinacy :: Determined )
619608 }
620609 Scope :: StdLibPrelude => {
@@ -637,11 +626,7 @@ impl<'a> Resolver<'a> {
637626 }
638627 Scope :: BuiltinTypes => match this. primitive_type_table . primitive_types
639628 . get ( & ident. name ) . cloned ( ) {
640- Some ( prim_ty) => {
641- let binding = ( Res :: PrimTy ( prim_ty) , ty:: Visibility :: Public ,
642- DUMMY_SP , ExpnId :: root ( ) ) . to_name_binding ( this. arenas ) ;
643- Ok ( ( binding, Flags :: empty ( ) ) )
644- }
629+ Some ( prim_ty) => ok ( Res :: PrimTy ( prim_ty) , DUMMY_SP , this. arenas ) ,
645630 None => Err ( Determinacy :: Determined )
646631 }
647632 } ;
0 commit comments