11use crate :: hir:: map:: definitions:: * ;
2- use crate :: hir:: def_id:: { CRATE_DEF_INDEX , DefIndex , DefIndexAddressSpace } ;
2+ use crate :: hir:: def_id:: { CRATE_DEF_INDEX , DefIndex } ;
33use crate :: session:: CrateDisambiguator ;
44
55use syntax:: ast:: * ;
@@ -10,8 +10,6 @@ use syntax::symbol::Symbol;
1010use syntax:: parse:: token:: { self , Token } ;
1111use syntax_pos:: Span ;
1212
13- use crate :: hir:: map:: { ITEM_LIKE_SPACE , REGULAR_SPACE } ;
14-
1513/// Creates `DefId`s for nodes in the AST.
1614pub struct DefCollector < ' a > {
1715 definitions : & ' a mut Definitions ,
@@ -47,13 +45,12 @@ impl<'a> DefCollector<'a> {
4745 fn create_def ( & mut self ,
4846 node_id : NodeId ,
4947 data : DefPathData ,
50- address_space : DefIndexAddressSpace ,
5148 span : Span )
5249 -> DefIndex {
5350 let parent_def = self . parent_def . unwrap ( ) ;
5451 debug ! ( "create_def(node_id={:?}, data={:?}, parent_def={:?})" , node_id, data, parent_def) ;
5552 self . definitions
56- . create_def_with_parent ( parent_def, node_id, data, address_space , self . expansion , span)
53+ . create_def_with_parent ( parent_def, node_id, data, self . expansion , span)
5754 }
5855
5956 pub fn with_parent < F : FnOnce ( & mut Self ) > ( & mut self , parent_def : DefIndex , f : F ) {
@@ -85,9 +82,9 @@ impl<'a> DefCollector<'a> {
8582 // For async functions, we need to create their inner defs inside of a
8683 // closure to match their desugared representation.
8784 let fn_def_data = DefPathData :: ValueNs ( name. as_interned_str ( ) ) ;
88- let fn_def = self . create_def ( id, fn_def_data, ITEM_LIKE_SPACE , span) ;
85+ let fn_def = self . create_def ( id, fn_def_data, span) ;
8986 return self . with_parent ( fn_def, |this| {
90- this. create_def ( * return_impl_trait_id, DefPathData :: ImplTrait , REGULAR_SPACE , span) ;
87+ this. create_def ( * return_impl_trait_id, DefPathData :: ImplTrait , span) ;
9188
9289 visit:: walk_generics ( this, generics) ;
9390
@@ -106,7 +103,7 @@ impl<'a> DefCollector<'a> {
106103 visit:: walk_fn_ret_ty ( this, & decl. output ) ;
107104
108105 let closure_def = this. create_def (
109- * closure_id, DefPathData :: ClosureExpr , REGULAR_SPACE , span,
106+ * closure_id, DefPathData :: ClosureExpr , span,
110107 ) ;
111108 this. with_parent ( closure_def, |this| {
112109 use visit:: Visitor ;
@@ -173,14 +170,14 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
173170 return visit:: walk_item ( self , i) ;
174171 }
175172 } ;
176- let def = self . create_def ( i. id , def_data, ITEM_LIKE_SPACE , i. span ) ;
173+ let def = self . create_def ( i. id , def_data, i. span ) ;
177174
178175 self . with_parent ( def, |this| {
179176 match i. node {
180177 ItemKind :: Struct ( ref struct_def, _) | ItemKind :: Union ( ref struct_def, _) => {
181178 // If this is a unit or tuple-like struct, register the constructor.
182179 if let Some ( ctor_hir_id) = struct_def. ctor_id ( ) {
183- this. create_def ( ctor_hir_id, DefPathData :: Ctor , REGULAR_SPACE , i. span ) ;
180+ this. create_def ( ctor_hir_id, DefPathData :: Ctor , i. span ) ;
184181 }
185182 }
186183 _ => { }
@@ -190,7 +187,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
190187 }
191188
192189 fn visit_use_tree ( & mut self , use_tree : & ' a UseTree , id : NodeId , _nested : bool ) {
193- self . create_def ( id, DefPathData :: Misc , ITEM_LIKE_SPACE , use_tree. span ) ;
190+ self . create_def ( id, DefPathData :: Misc , use_tree. span ) ;
194191 visit:: walk_use_tree ( self , use_tree, id) ;
195192 }
196193
@@ -201,7 +198,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
201198
202199 let def = self . create_def ( foreign_item. id ,
203200 DefPathData :: ValueNs ( foreign_item. ident . as_interned_str ( ) ) ,
204- REGULAR_SPACE ,
205201 foreign_item. span ) ;
206202
207203 self . with_parent ( def, |this| {
@@ -212,11 +208,10 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
212208 fn visit_variant ( & mut self , v : & ' a Variant , g : & ' a Generics , item_id : NodeId ) {
213209 let def = self . create_def ( v. node . id ,
214210 DefPathData :: TypeNs ( v. node . ident . as_interned_str ( ) ) ,
215- REGULAR_SPACE ,
216211 v. span ) ;
217212 self . with_parent ( def, |this| {
218213 if let Some ( ctor_hir_id) = v. node . data . ctor_id ( ) {
219- this. create_def ( ctor_hir_id, DefPathData :: Ctor , REGULAR_SPACE , v. span ) ;
214+ this. create_def ( ctor_hir_id, DefPathData :: Ctor , v. span ) ;
220215 }
221216 visit:: walk_variant ( this, v, g, item_id)
222217 } ) ;
@@ -229,7 +224,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
229224 . unwrap_or_else ( || Symbol :: intern ( & index. to_string ( ) ) ) ;
230225 let def = self . create_def ( field. id ,
231226 DefPathData :: ValueNs ( name. as_interned_str ( ) ) ,
232- REGULAR_SPACE ,
233227 field. span ) ;
234228 self . with_parent ( def, |this| this. visit_struct_field ( field) ) ;
235229 }
@@ -242,7 +236,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
242236 GenericParamKind :: Type { .. } => DefPathData :: TypeNs ( name) ,
243237 GenericParamKind :: Const { .. } => DefPathData :: ValueNs ( name) ,
244238 } ;
245- self . create_def ( param. id , def_path_data, REGULAR_SPACE , param. ident . span ) ;
239+ self . create_def ( param. id , def_path_data, param. ident . span ) ;
246240
247241 visit:: walk_generic_param ( self , param) ;
248242 }
@@ -257,7 +251,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
257251 TraitItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ti. id ) ,
258252 } ;
259253
260- let def = self . create_def ( ti. id , def_data, ITEM_LIKE_SPACE , ti. span ) ;
254+ let def = self . create_def ( ti. id , def_data, ti. span ) ;
261255 self . with_parent ( def, |this| visit:: walk_trait_item ( this, ti) ) ;
262256 }
263257
@@ -286,7 +280,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
286280 ImplItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ii. id ) ,
287281 } ;
288282
289- let def = self . create_def ( ii. id , def_data, ITEM_LIKE_SPACE , ii. span ) ;
283+ let def = self . create_def ( ii. id , def_data, ii. span ) ;
290284 self . with_parent ( def, |this| visit:: walk_impl_item ( this, ii) ) ;
291285 }
292286
@@ -300,7 +294,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
300294 fn visit_anon_const ( & mut self , constant : & ' a AnonConst ) {
301295 let def = self . create_def ( constant. id ,
302296 DefPathData :: AnonConst ,
303- REGULAR_SPACE ,
304297 constant. value . span ) ;
305298 self . with_parent ( def, |this| visit:: walk_anon_const ( this, constant) ) ;
306299 }
@@ -313,7 +306,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
313306 ExprKind :: Closure ( _, ref asyncness, ..) => {
314307 let closure_def = self . create_def ( expr. id ,
315308 DefPathData :: ClosureExpr ,
316- REGULAR_SPACE ,
317309 expr. span ) ;
318310 self . parent_def = Some ( closure_def) ;
319311
@@ -322,15 +314,13 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
322314 if let IsAsync :: Async { closure_id, .. } = asyncness {
323315 let async_def = self . create_def ( * closure_id,
324316 DefPathData :: ClosureExpr ,
325- REGULAR_SPACE ,
326317 expr. span ) ;
327318 self . parent_def = Some ( async_def) ;
328319 }
329320 }
330321 ExprKind :: Async ( _, async_id, _) => {
331322 let async_def = self . create_def ( async_id,
332323 DefPathData :: ClosureExpr ,
333- REGULAR_SPACE ,
334324 expr. span ) ;
335325 self . parent_def = Some ( async_def) ;
336326 }
@@ -345,7 +335,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
345335 match ty. node {
346336 TyKind :: Mac ( ..) => return self . visit_macro_invoc ( ty. id ) ,
347337 TyKind :: ImplTrait ( node_id, _) => {
348- self . create_def ( node_id, DefPathData :: ImplTrait , REGULAR_SPACE , ty. span ) ;
338+ self . create_def ( node_id, DefPathData :: ImplTrait , ty. span ) ;
349339 }
350340 _ => { }
351341 }
0 commit comments