@@ -492,6 +492,10 @@ impl<'a> Resolver<'a> {
492
492
// Go through all the scopes and try to resolve the name.
493
493
let break_result = self . visit_scopes ( scope_set, parent_scope, orig_ident,
494
494
|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
+ ) ) ;
495
499
let result = match scope {
496
500
Scope :: DeriveHelpers => {
497
501
let mut result = Err ( Determinacy :: Determined ) ;
@@ -500,10 +504,8 @@ impl<'a> Resolver<'a> {
500
504
match this. resolve_macro_path ( derive, Some ( MacroKind :: Derive ) ,
501
505
parent_scope, true , force) {
502
506
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 ) ;
507
509
break ;
508
510
}
509
511
Ok ( _) | Err ( Determinacy :: Determined ) => { }
@@ -571,12 +573,9 @@ impl<'a> Resolver<'a> {
571
573
}
572
574
}
573
575
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
+ ) ,
580
579
None => Err ( Determinacy :: Determined )
581
580
}
582
581
Scope :: MacroUsePrelude => match this. macro_use_prelude . get ( & ident. name ) . cloned ( ) {
@@ -586,19 +585,14 @@ impl<'a> Resolver<'a> {
586
585
) )
587
586
}
588
587
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 )
593
589
} else {
594
590
Err ( Determinacy :: Determined )
595
591
}
596
592
Scope :: LegacyPluginHelpers => if this. session . plugin_attributes . borrow ( ) . iter ( )
597
593
. 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 )
602
596
} else {
603
597
Err ( Determinacy :: Determined )
604
598
}
@@ -609,12 +603,7 @@ impl<'a> Resolver<'a> {
609
603
) ) ,
610
604
}
611
605
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 ) ,
618
607
None => Err ( Determinacy :: Determined )
619
608
}
620
609
Scope :: StdLibPrelude => {
@@ -637,11 +626,7 @@ impl<'a> Resolver<'a> {
637
626
}
638
627
Scope :: BuiltinTypes => match this. primitive_type_table . primitive_types
639
628
. 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 ) ,
645
630
None => Err ( Determinacy :: Determined )
646
631
}
647
632
} ;
0 commit comments