@@ -97,17 +97,6 @@ mod check_unused;
9797mod build_reduced_graph;
9898mod resolve_imports;
9999
100- // Perform the callback, not walking deeper if the return is true
101- macro_rules! execute_callback {
102- ( $node: expr, $walker: expr) => (
103- if let Some ( ref callback) = $walker. callback {
104- if callback( $node, & mut $walker. resolved) {
105- return ;
106- }
107- }
108- )
109- }
110-
111100enum SuggestionType {
112101 Macro ( String ) ,
113102 Function ( token:: InternedString ) ,
@@ -559,22 +548,18 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
559548 self . visit_item ( self . ast_map . expect_item ( item. id ) )
560549 }
561550 fn visit_item ( & mut self , item : & Item ) {
562- execute_callback ! ( hir_map:: Node :: NodeItem ( item) , self ) ;
563551 self . resolve_item ( item) ;
564552 }
565553 fn visit_arm ( & mut self , arm : & Arm ) {
566554 self . resolve_arm ( arm) ;
567555 }
568556 fn visit_block ( & mut self , block : & Block ) {
569- execute_callback ! ( hir_map:: Node :: NodeBlock ( block) , self ) ;
570557 self . resolve_block ( block) ;
571558 }
572559 fn visit_expr ( & mut self , expr : & Expr ) {
573- execute_callback ! ( hir_map:: Node :: NodeExpr ( expr) , self ) ;
574560 self . resolve_expr ( expr) ;
575561 }
576562 fn visit_local ( & mut self , local : & Local ) {
577- execute_callback ! ( hir_map:: Node :: NodeLocal ( & local. pat) , self ) ;
578563 self . resolve_local ( local) ;
579564 }
580565 fn visit_ty ( & mut self , ty : & Ty ) {
@@ -597,7 +582,6 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
597582 variant : & hir:: Variant ,
598583 generics : & Generics ,
599584 item_id : ast:: NodeId ) {
600- execute_callback ! ( hir_map:: Node :: NodeVariant ( variant) , self ) ;
601585 if let Some ( ref dis_expr) = variant. node . disr_expr {
602586 // resolve the discriminator expr as a constant
603587 self . with_constant_rib ( |this| {
@@ -613,7 +597,6 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
613597 variant. span ) ;
614598 }
615599 fn visit_foreign_item ( & mut self , foreign_item : & hir:: ForeignItem ) {
616- execute_callback ! ( hir_map:: Node :: NodeForeignItem ( foreign_item) , self ) ;
617600 let type_parameters = match foreign_item. node {
618601 ForeignItemFn ( _, ref generics) => {
619602 HasTypeParameters ( generics, FnSpace , ItemRibKind )
@@ -1080,11 +1063,6 @@ pub struct Resolver<'a, 'tcx: 'a> {
10801063 used_imports : HashSet < ( NodeId , Namespace ) > ,
10811064 used_crates : HashSet < CrateNum > ,
10821065
1083- // Callback function for intercepting walks
1084- callback : Option < Box < Fn ( hir_map:: Node , & mut bool ) -> bool > > ,
1085- // The intention is that the callback modifies this flag.
1086- // Once set, the resolver falls out of the walk, preserving the ribs.
1087- resolved : bool ,
10881066 privacy_errors : Vec < PrivacyError < ' a > > ,
10891067
10901068 arenas : & ' a ResolverArenas < ' a > ,
@@ -1186,8 +1164,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11861164 make_glob_map : make_glob_map == MakeGlobMap :: Yes ,
11871165 glob_map : NodeMap ( ) ,
11881166
1189- callback : None ,
1190- resolved : false ,
11911167 privacy_errors : Vec :: new ( ) ,
11921168
11931169 arenas : arenas,
@@ -1758,13 +1734,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17581734
17591735 f ( self ) ;
17601736
1761- match type_parameters {
1762- HasTypeParameters ( ..) => {
1763- if !self . resolved {
1764- self . type_ribs . pop ( ) ;
1765- }
1766- }
1767- NoTypeParameters => { }
1737+ if let HasTypeParameters ( ..) = type_parameters {
1738+ self . type_ribs . pop ( ) ;
17681739 }
17691740 }
17701741
@@ -1773,9 +1744,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17731744 {
17741745 self . label_ribs . push ( Rib :: new ( NormalRibKind ) ) ;
17751746 f ( self ) ;
1776- if !self . resolved {
1777- self . label_ribs . pop ( ) ;
1778- }
1747+ self . label_ribs . pop ( ) ;
17791748 }
17801749
17811750 fn with_constant_rib < F > ( & mut self , f : F )
@@ -1784,10 +1753,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17841753 self . value_ribs . push ( Rib :: new ( ConstantItemRibKind ) ) ;
17851754 self . type_ribs . push ( Rib :: new ( ConstantItemRibKind ) ) ;
17861755 f ( self ) ;
1787- if !self . resolved {
1788- self . type_ribs . pop ( ) ;
1789- self . value_ribs . pop ( ) ;
1790- }
1756+ self . type_ribs . pop ( ) ;
1757+ self . value_ribs . pop ( ) ;
17911758 }
17921759
17931760 fn resolve_function ( & mut self , rib_kind : RibKind < ' a > , declaration : & FnDecl , block : & Block ) {
@@ -1813,10 +1780,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18131780
18141781 debug ! ( "(resolving function) leaving function" ) ;
18151782
1816- if !self . resolved {
1817- self . label_ribs . pop ( ) ;
1818- self . value_ribs . pop ( ) ;
1819- }
1783+ self . label_ribs . pop ( ) ;
1784+ self . value_ribs . pop ( ) ;
18201785 }
18211786
18221787 fn resolve_trait_reference ( & mut self ,
@@ -1950,9 +1915,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19501915 self_type_rib. bindings . insert ( keywords:: SelfType . name ( ) , self_def) ;
19511916 self . type_ribs . push ( self_type_rib) ;
19521917 f ( self ) ;
1953- if !self . resolved {
1954- self . type_ribs . pop ( ) ;
1955- }
1918+ self . type_ribs . pop ( ) ;
19561919 }
19571920
19581921 fn resolve_implementation ( & mut self ,
@@ -2117,9 +2080,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21172080 walk_list ! ( self , visit_expr, & arm. guard) ;
21182081 self . visit_expr ( & arm. body ) ;
21192082
2120- if !self . resolved {
2121- self . value_ribs . pop ( ) ;
2122- }
2083+ self . value_ribs . pop ( ) ;
21232084 }
21242085
21252086 fn resolve_block ( & mut self , block : & Block ) {
@@ -2141,12 +2102,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21412102 intravisit:: walk_block ( self , block) ;
21422103
21432104 // Move back up.
2144- if !self . resolved {
2145- self . current_module = orig_module;
2146- self . value_ribs . pop ( ) ;
2147- if let Some ( _) = anonymous_module {
2148- self . type_ribs . pop ( ) ;
2149- }
2105+ self . current_module = orig_module;
2106+ self . value_ribs . pop ( ) ;
2107+ if let Some ( _) = anonymous_module {
2108+ self . type_ribs . pop ( ) ;
21502109 }
21512110 debug ! ( "(resolving block) leaving block" ) ;
21522111 }
@@ -3588,7 +3547,7 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
35883547
35893548 let krate = ast_map. krate ( ) ;
35903549 let arenas = Resolver :: arenas ( ) ;
3591- let mut resolver = create_resolver ( session, ast_map, krate, make_glob_map, & arenas, None ) ;
3550+ let mut resolver = create_resolver ( session, ast_map, krate, make_glob_map, & arenas) ;
35923551
35933552 resolver. resolve_crate ( krate) ;
35943553
@@ -3608,25 +3567,15 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
36083567 }
36093568}
36103569
3611- /// Builds a name resolution walker to be used within this module,
3612- /// or used externally, with an optional callback function.
3613- ///
3614- /// The callback takes a &mut bool which allows callbacks to end a
3615- /// walk when set to true, passing through the rest of the walk, while
3616- /// preserving the ribs + current module. This allows resolve_path
3617- /// calls to be made with the correct scope info. The node in the
3618- /// callback corresponds to the current node in the walk.
3570+ /// Builds a name resolution walker.
36193571fn create_resolver < ' a , ' tcx > ( session : & ' a Session ,
36203572 ast_map : & ' a hir_map:: Map < ' tcx > ,
36213573 krate : & ' a Crate ,
36223574 make_glob_map : MakeGlobMap ,
3623- arenas : & ' a ResolverArenas < ' a > ,
3624- callback : Option < Box < Fn ( hir_map:: Node , & mut bool ) -> bool > > )
3575+ arenas : & ' a ResolverArenas < ' a > )
36253576 -> Resolver < ' a , ' tcx > {
36263577 let mut resolver = Resolver :: new ( session, ast_map, make_glob_map, arenas) ;
36273578
3628- resolver. callback = callback;
3629-
36303579 resolver. build_reduced_graph ( krate) ;
36313580
36323581 resolve_imports:: resolve_imports ( & mut resolver) ;
0 commit comments