@@ -30,6 +30,7 @@ use syntax::attr;
30
30
use syntax:: ast:: { self , Block , ForeignItem , ForeignItemKind , Item , ItemKind , NodeId } ;
31
31
use syntax:: ast:: { MetaItemKind , StmtKind , TraitItem , TraitItemKind , Variant } ;
32
32
use syntax:: ext:: base:: { MacroKind , SyntaxExtension } ;
33
+ use syntax:: ext:: expand:: AstFragment ;
33
34
use syntax:: ext:: hygiene:: ExpnId ;
34
35
use syntax:: feature_gate:: is_builtin_attr;
35
36
use syntax:: parse:: token:: { self , Token } ;
@@ -67,7 +68,7 @@ impl<'a> ToNameBinding<'a> for (Res, ty::Visibility, Span, ExpnId) {
67
68
}
68
69
}
69
70
70
- pub ( crate ) struct IsMacroExport ;
71
+ struct IsMacroExport ;
71
72
72
73
impl < ' a > ToNameBinding < ' a > for ( Res , ty:: Visibility , Span , ExpnId , IsMacroExport ) {
73
74
fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
@@ -84,7 +85,7 @@ impl<'a> ToNameBinding<'a> for (Res, ty::Visibility, Span, ExpnId, IsMacroExport
84
85
impl < ' a > Resolver < ' a > {
85
86
/// Defines `name` in namespace `ns` of module `parent` to be `def` if it is not yet defined;
86
87
/// otherwise, reports an error.
87
- pub fn define < T > ( & mut self , parent : Module < ' a > , ident : Ident , ns : Namespace , def : T )
88
+ crate fn define < T > ( & mut self , parent : Module < ' a > , ident : Ident , ns : Namespace , def : T )
88
89
where T : ToNameBinding < ' a > ,
89
90
{
90
91
let binding = def. to_name_binding ( self . arenas ) ;
@@ -93,7 +94,7 @@ impl<'a> Resolver<'a> {
93
94
}
94
95
}
95
96
96
- pub fn get_module ( & mut self , def_id : DefId ) -> Module < ' a > {
97
+ crate fn get_module ( & mut self , def_id : DefId ) -> Module < ' a > {
97
98
if def_id. krate == LOCAL_CRATE {
98
99
return self . module_map [ & def_id]
99
100
}
@@ -119,7 +120,7 @@ impl<'a> Resolver<'a> {
119
120
module
120
121
}
121
122
122
- pub fn macro_def_scope ( & mut self , expn_id : ExpnId ) -> Module < ' a > {
123
+ crate fn macro_def_scope ( & mut self , expn_id : ExpnId ) -> Module < ' a > {
123
124
let def_id = match self . macro_defs . get ( & expn_id) {
124
125
Some ( def_id) => * def_id,
125
126
None => return self . graph_root ,
@@ -141,7 +142,7 @@ impl<'a> Resolver<'a> {
141
142
}
142
143
}
143
144
144
- crate fn get_macro_by_def_id ( & mut self , def_id : DefId ) -> Option < Lrc < SyntaxExtension > > {
145
+ fn get_macro_by_def_id ( & mut self , def_id : DefId ) -> Option < Lrc < SyntaxExtension > > {
145
146
if let Some ( ext) = self . macro_map . get ( & def_id) {
146
147
return Some ( ext. clone ( ) ) ;
147
148
}
@@ -158,7 +159,7 @@ impl<'a> Resolver<'a> {
158
159
159
160
/// Ensures that the reduced graph rooted at the given external module
160
161
/// is built, building it if it is not.
161
- pub fn populate_module_if_necessary ( & mut self , module : Module < ' a > ) {
162
+ crate fn populate_module_if_necessary ( & mut self , module : Module < ' a > ) {
162
163
if module. populated . get ( ) { return }
163
164
let def_id = module. def_id ( ) . unwrap ( ) ;
164
165
for child in self . cstore . item_children_untracked ( def_id, self . session ) {
@@ -168,11 +169,19 @@ impl<'a> Resolver<'a> {
168
169
}
169
170
module. populated . set ( true )
170
171
}
172
+
173
+ crate fn build_reduced_graph (
174
+ & mut self , fragment : & AstFragment , parent_scope : ParentScope < ' a >
175
+ ) -> LegacyScope < ' a > {
176
+ let mut visitor = BuildReducedGraphVisitor { r : self , parent_scope } ;
177
+ fragment. visit_with ( & mut visitor) ;
178
+ visitor. parent_scope . legacy
179
+ }
171
180
}
172
181
173
- pub struct BuildReducedGraphVisitor < ' a , ' b > {
174
- pub r : & ' b mut Resolver < ' a > ,
175
- pub parent_scope : ParentScope < ' a > ,
182
+ struct BuildReducedGraphVisitor < ' a , ' b > {
183
+ r : & ' b mut Resolver < ' a > ,
184
+ parent_scope : ParentScope < ' a > ,
176
185
}
177
186
178
187
impl < ' a , ' b > BuildReducedGraphVisitor < ' a , ' b > {
0 commit comments