1
1
use 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 } ;
3
3
use crate :: session:: CrateDisambiguator ;
4
4
5
5
use syntax:: ast:: * ;
@@ -10,8 +10,6 @@ use syntax::symbol::Symbol;
10
10
use syntax:: parse:: token:: { self , Token } ;
11
11
use syntax_pos:: Span ;
12
12
13
- use crate :: hir:: map:: { ITEM_LIKE_SPACE , REGULAR_SPACE } ;
14
-
15
13
/// Creates `DefId`s for nodes in the AST.
16
14
pub struct DefCollector < ' a > {
17
15
definitions : & ' a mut Definitions ,
@@ -47,13 +45,12 @@ impl<'a> DefCollector<'a> {
47
45
fn create_def ( & mut self ,
48
46
node_id : NodeId ,
49
47
data : DefPathData ,
50
- address_space : DefIndexAddressSpace ,
51
48
span : Span )
52
49
-> DefIndex {
53
50
let parent_def = self . parent_def . unwrap ( ) ;
54
51
debug ! ( "create_def(node_id={:?}, data={:?}, parent_def={:?})" , node_id, data, parent_def) ;
55
52
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)
57
54
}
58
55
59
56
pub fn with_parent < F : FnOnce ( & mut Self ) > ( & mut self , parent_def : DefIndex , f : F ) {
@@ -85,9 +82,9 @@ impl<'a> DefCollector<'a> {
85
82
// For async functions, we need to create their inner defs inside of a
86
83
// closure to match their desugared representation.
87
84
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) ;
89
86
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) ;
91
88
92
89
visit:: walk_generics ( this, generics) ;
93
90
@@ -106,7 +103,7 @@ impl<'a> DefCollector<'a> {
106
103
visit:: walk_fn_ret_ty ( this, & decl. output ) ;
107
104
108
105
let closure_def = this. create_def (
109
- * closure_id, DefPathData :: ClosureExpr , REGULAR_SPACE , span,
106
+ * closure_id, DefPathData :: ClosureExpr , span,
110
107
) ;
111
108
this. with_parent ( closure_def, |this| {
112
109
use visit:: Visitor ;
@@ -173,14 +170,14 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
173
170
return visit:: walk_item ( self , i) ;
174
171
}
175
172
} ;
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 ) ;
177
174
178
175
self . with_parent ( def, |this| {
179
176
match i. node {
180
177
ItemKind :: Struct ( ref struct_def, _) | ItemKind :: Union ( ref struct_def, _) => {
181
178
// If this is a unit or tuple-like struct, register the constructor.
182
179
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 ) ;
184
181
}
185
182
}
186
183
_ => { }
@@ -190,7 +187,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
190
187
}
191
188
192
189
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 ) ;
194
191
visit:: walk_use_tree ( self , use_tree, id) ;
195
192
}
196
193
@@ -201,7 +198,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
201
198
202
199
let def = self . create_def ( foreign_item. id ,
203
200
DefPathData :: ValueNs ( foreign_item. ident . as_interned_str ( ) ) ,
204
- REGULAR_SPACE ,
205
201
foreign_item. span ) ;
206
202
207
203
self . with_parent ( def, |this| {
@@ -212,11 +208,10 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
212
208
fn visit_variant ( & mut self , v : & ' a Variant , g : & ' a Generics , item_id : NodeId ) {
213
209
let def = self . create_def ( v. node . id ,
214
210
DefPathData :: TypeNs ( v. node . ident . as_interned_str ( ) ) ,
215
- REGULAR_SPACE ,
216
211
v. span ) ;
217
212
self . with_parent ( def, |this| {
218
213
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 ) ;
220
215
}
221
216
visit:: walk_variant ( this, v, g, item_id)
222
217
} ) ;
@@ -229,7 +224,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
229
224
. unwrap_or_else ( || Symbol :: intern ( & index. to_string ( ) ) ) ;
230
225
let def = self . create_def ( field. id ,
231
226
DefPathData :: ValueNs ( name. as_interned_str ( ) ) ,
232
- REGULAR_SPACE ,
233
227
field. span ) ;
234
228
self . with_parent ( def, |this| this. visit_struct_field ( field) ) ;
235
229
}
@@ -242,7 +236,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
242
236
GenericParamKind :: Type { .. } => DefPathData :: TypeNs ( name) ,
243
237
GenericParamKind :: Const { .. } => DefPathData :: ValueNs ( name) ,
244
238
} ;
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 ) ;
246
240
247
241
visit:: walk_generic_param ( self , param) ;
248
242
}
@@ -257,7 +251,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
257
251
TraitItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ti. id ) ,
258
252
} ;
259
253
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 ) ;
261
255
self . with_parent ( def, |this| visit:: walk_trait_item ( this, ti) ) ;
262
256
}
263
257
@@ -286,7 +280,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
286
280
ImplItemKind :: Macro ( ..) => return self . visit_macro_invoc ( ii. id ) ,
287
281
} ;
288
282
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 ) ;
290
284
self . with_parent ( def, |this| visit:: walk_impl_item ( this, ii) ) ;
291
285
}
292
286
@@ -300,7 +294,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
300
294
fn visit_anon_const ( & mut self , constant : & ' a AnonConst ) {
301
295
let def = self . create_def ( constant. id ,
302
296
DefPathData :: AnonConst ,
303
- REGULAR_SPACE ,
304
297
constant. value . span ) ;
305
298
self . with_parent ( def, |this| visit:: walk_anon_const ( this, constant) ) ;
306
299
}
@@ -313,7 +306,6 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
313
306
ExprKind :: Closure ( _, ref asyncness, ..) => {
314
307
let closure_def = self . create_def ( expr. id ,
315
308
DefPathData :: ClosureExpr ,
316
- REGULAR_SPACE ,
317
309
expr. span ) ;
318
310
self . parent_def = Some ( closure_def) ;
319
311
@@ -322,15 +314,13 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
322
314
if let IsAsync :: Async { closure_id, .. } = asyncness {
323
315
let async_def = self . create_def ( * closure_id,
324
316
DefPathData :: ClosureExpr ,
325
- REGULAR_SPACE ,
326
317
expr. span ) ;
327
318
self . parent_def = Some ( async_def) ;
328
319
}
329
320
}
330
321
ExprKind :: Async ( _, async_id, _) => {
331
322
let async_def = self . create_def ( async_id,
332
323
DefPathData :: ClosureExpr ,
333
- REGULAR_SPACE ,
334
324
expr. span ) ;
335
325
self . parent_def = Some ( async_def) ;
336
326
}
@@ -345,7 +335,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
345
335
match ty. node {
346
336
TyKind :: Mac ( ..) => return self . visit_macro_invoc ( ty. id ) ,
347
337
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 ) ;
349
339
}
350
340
_ => { }
351
341
}
0 commit comments