@@ -13,8 +13,7 @@ use std::io::Write;
13
13
use rustc_serialize:: json:: as_json;
14
14
use syntax:: codemap:: CodeMap ;
15
15
16
- use rustc:: hir:: def_id:: DefId ;
17
- use syntax:: ast:: { CrateNum , NodeId } ;
16
+ use syntax:: ast:: CrateNum ;
18
17
19
18
use super :: data:: { self , SpanData } ;
20
19
use super :: dump:: Dump ;
@@ -92,6 +91,8 @@ trait Lower {
92
91
fn lower ( self , cm : & CodeMap ) -> Self :: Target ;
93
92
}
94
93
94
+ pub type Id = u32 ;
95
+
95
96
#[ derive( Debug , RustcEncodable ) ]
96
97
pub struct CratePreludeData {
97
98
pub crate_name : String ,
@@ -116,11 +117,11 @@ impl Lower for data::CratePreludeData {
116
117
/// Data for enum declarations.
117
118
#[ derive( Clone , Debug , RustcEncodable ) ]
118
119
pub struct EnumData {
119
- pub id : NodeId ,
120
+ pub id : Id ,
120
121
pub value : String ,
121
122
pub qualname : String ,
122
123
pub span : SpanData ,
123
- pub scope : NodeId ,
124
+ pub scope : Id ,
124
125
}
125
126
126
127
impl Lower for data:: EnumData {
@@ -140,12 +141,12 @@ impl Lower for data::EnumData {
140
141
/// Data for extern crates.
141
142
#[ derive( Debug , RustcEncodable ) ]
142
143
pub struct ExternCrateData {
143
- pub id : NodeId ,
144
+ pub id : Id ,
144
145
pub name : String ,
145
146
pub crate_num : CrateNum ,
146
147
pub location : String ,
147
148
pub span : SpanData ,
148
- pub scope : NodeId ,
149
+ pub scope : Id ,
149
150
}
150
151
151
152
impl Lower for data:: ExternCrateData {
@@ -167,8 +168,8 @@ impl Lower for data::ExternCrateData {
167
168
#[ derive( Debug , RustcEncodable ) ]
168
169
pub struct FunctionCallData {
169
170
pub span : SpanData ,
170
- pub scope : NodeId ,
171
- pub ref_id : DefId ,
171
+ pub scope : Id ,
172
+ pub ref_id : Id ,
172
173
}
173
174
174
175
impl Lower for data:: FunctionCallData {
@@ -178,20 +179,20 @@ impl Lower for data::FunctionCallData {
178
179
FunctionCallData {
179
180
span : SpanData :: from_span ( self . span , cm) ,
180
181
scope : self . scope ,
181
- ref_id : self . ref_id ,
182
+ ref_id : self . ref_id . index . as_u32 ( ) ,
182
183
}
183
184
}
184
185
}
185
186
186
187
/// Data for all kinds of functions and methods.
187
188
#[ derive( Clone , Debug , RustcEncodable ) ]
188
189
pub struct FunctionData {
189
- pub id : NodeId ,
190
+ pub id : Id ,
190
191
pub name : String ,
191
192
pub qualname : String ,
192
- pub declaration : Option < DefId > ,
193
+ pub declaration : Option < Id > ,
193
194
pub span : SpanData ,
194
- pub scope : NodeId ,
195
+ pub scope : Id ,
195
196
}
196
197
197
198
impl Lower for data:: FunctionData {
@@ -202,7 +203,7 @@ impl Lower for data::FunctionData {
202
203
id : self . id ,
203
204
name : self . name ,
204
205
qualname : self . qualname ,
205
- declaration : self . declaration ,
206
+ declaration : self . declaration . map ( |id| id . index . as_u32 ( ) ) ,
206
207
span : SpanData :: from_span ( self . span , cm) ,
207
208
scope : self . scope ,
208
209
}
@@ -213,8 +214,8 @@ impl Lower for data::FunctionData {
213
214
#[ derive( Debug , RustcEncodable ) ]
214
215
pub struct FunctionRefData {
215
216
pub span : SpanData ,
216
- pub scope : NodeId ,
217
- pub ref_id : DefId ,
217
+ pub scope : Id ,
218
+ pub ref_id : Id ,
218
219
}
219
220
220
221
impl Lower for data:: FunctionRefData {
@@ -224,17 +225,17 @@ impl Lower for data::FunctionRefData {
224
225
FunctionRefData {
225
226
span : SpanData :: from_span ( self . span , cm) ,
226
227
scope : self . scope ,
227
- ref_id : self . ref_id ,
228
+ ref_id : self . ref_id . index . as_u32 ( ) ,
228
229
}
229
230
}
230
231
}
231
232
#[ derive( Debug , RustcEncodable ) ]
232
233
pub struct ImplData {
233
- pub id : NodeId ,
234
+ pub id : Id ,
234
235
pub span : SpanData ,
235
- pub scope : NodeId ,
236
- pub trait_ref : Option < DefId > ,
237
- pub self_ref : Option < DefId > ,
236
+ pub scope : Id ,
237
+ pub trait_ref : Option < Id > ,
238
+ pub self_ref : Option < Id > ,
238
239
}
239
240
240
241
impl Lower for data:: ImplData {
@@ -245,17 +246,17 @@ impl Lower for data::ImplData {
245
246
id : self . id ,
246
247
span : SpanData :: from_span ( self . span , cm) ,
247
248
scope : self . scope ,
248
- trait_ref : self . trait_ref ,
249
- self_ref : self . self_ref ,
249
+ trait_ref : self . trait_ref . map ( |id| id . index . as_u32 ( ) ) ,
250
+ self_ref : self . self_ref . map ( |id| id . index . as_u32 ( ) ) ,
250
251
}
251
252
}
252
253
}
253
254
254
255
#[ derive( Debug , RustcEncodable ) ]
255
256
pub struct InheritanceData {
256
257
pub span : SpanData ,
257
- pub base_id : DefId ,
258
- pub deriv_id : NodeId
258
+ pub base_id : Id ,
259
+ pub deriv_id : Id
259
260
}
260
261
261
262
impl Lower for data:: InheritanceData {
@@ -264,7 +265,7 @@ impl Lower for data::InheritanceData {
264
265
fn lower ( self , cm : & CodeMap ) -> InheritanceData {
265
266
InheritanceData {
266
267
span : SpanData :: from_span ( self . span , cm) ,
267
- base_id : self . base_id ,
268
+ base_id : self . base_id . index . as_u32 ( ) ,
268
269
deriv_id : self . deriv_id
269
270
}
270
271
}
@@ -299,7 +300,7 @@ pub struct MacroUseData {
299
300
// Because macro expansion happens before ref-ids are determined,
300
301
// we use the callee span to reference the associated macro definition.
301
302
pub callee_span : SpanData ,
302
- pub scope : NodeId ,
303
+ pub scope : Id ,
303
304
pub imported : bool ,
304
305
}
305
306
@@ -322,9 +323,9 @@ impl Lower for data::MacroUseData {
322
323
#[ derive( Debug , RustcEncodable ) ]
323
324
pub struct MethodCallData {
324
325
pub span : SpanData ,
325
- pub scope : NodeId ,
326
- pub ref_id : Option < DefId > ,
327
- pub decl_id : Option < DefId > ,
326
+ pub scope : Id ,
327
+ pub ref_id : Option < Id > ,
328
+ pub decl_id : Option < Id > ,
328
329
}
329
330
330
331
impl Lower for data:: MethodCallData {
@@ -334,19 +335,19 @@ impl Lower for data::MethodCallData {
334
335
MethodCallData {
335
336
span : SpanData :: from_span ( self . span , cm) ,
336
337
scope : self . scope ,
337
- ref_id : self . ref_id ,
338
- decl_id : self . decl_id ,
338
+ ref_id : self . ref_id . map ( |id| id . index . as_u32 ( ) ) ,
339
+ decl_id : self . decl_id . map ( |id| id . index . as_u32 ( ) ) ,
339
340
}
340
341
}
341
342
}
342
343
343
344
/// Data for method declarations (methods with a body are treated as functions).
344
345
#[ derive( Clone , Debug , RustcEncodable ) ]
345
346
pub struct MethodData {
346
- pub id : NodeId ,
347
+ pub id : Id ,
347
348
pub qualname : String ,
348
349
pub span : SpanData ,
349
- pub scope : NodeId ,
350
+ pub scope : Id ,
350
351
}
351
352
352
353
impl Lower for data:: MethodData {
@@ -365,11 +366,11 @@ impl Lower for data::MethodData {
365
366
/// Data for modules.
366
367
#[ derive( Debug , RustcEncodable ) ]
367
368
pub struct ModData {
368
- pub id : NodeId ,
369
+ pub id : Id ,
369
370
pub name : String ,
370
371
pub qualname : String ,
371
372
pub span : SpanData ,
372
- pub scope : NodeId ,
373
+ pub scope : Id ,
373
374
pub filename : String ,
374
375
}
375
376
@@ -392,8 +393,8 @@ impl Lower for data::ModData {
392
393
#[ derive( Debug , RustcEncodable ) ]
393
394
pub struct ModRefData {
394
395
pub span : SpanData ,
395
- pub scope : NodeId ,
396
- pub ref_id : Option < DefId > ,
396
+ pub scope : Id ,
397
+ pub ref_id : Option < Id > ,
397
398
pub qualname : String
398
399
}
399
400
@@ -404,7 +405,7 @@ impl Lower for data::ModRefData {
404
405
ModRefData {
405
406
span : SpanData :: from_span ( self . span , cm) ,
406
407
scope : self . scope ,
407
- ref_id : self . ref_id ,
408
+ ref_id : self . ref_id . map ( |id| id . index . as_u32 ( ) ) ,
408
409
qualname : self . qualname ,
409
410
}
410
411
}
@@ -413,10 +414,10 @@ impl Lower for data::ModRefData {
413
414
#[ derive( Debug , RustcEncodable ) ]
414
415
pub struct StructData {
415
416
pub span : SpanData ,
416
- pub id : NodeId ,
417
- pub ctor_id : NodeId ,
417
+ pub id : Id ,
418
+ pub ctor_id : Id ,
418
419
pub qualname : String ,
419
- pub scope : NodeId ,
420
+ pub scope : Id ,
420
421
pub value : String
421
422
}
422
423
@@ -438,11 +439,11 @@ impl Lower for data::StructData {
438
439
#[ derive( Debug , RustcEncodable ) ]
439
440
pub struct StructVariantData {
440
441
pub span : SpanData ,
441
- pub id : NodeId ,
442
+ pub id : Id ,
442
443
pub qualname : String ,
443
444
pub type_value : String ,
444
445
pub value : String ,
445
- pub scope : NodeId
446
+ pub scope : Id
446
447
}
447
448
448
449
impl Lower for data:: StructVariantData {
@@ -463,9 +464,9 @@ impl Lower for data::StructVariantData {
463
464
#[ derive( Debug , RustcEncodable ) ]
464
465
pub struct TraitData {
465
466
pub span : SpanData ,
466
- pub id : NodeId ,
467
+ pub id : Id ,
467
468
pub qualname : String ,
468
- pub scope : NodeId ,
469
+ pub scope : Id ,
469
470
pub value : String
470
471
}
471
472
@@ -486,12 +487,12 @@ impl Lower for data::TraitData {
486
487
#[ derive( Debug , RustcEncodable ) ]
487
488
pub struct TupleVariantData {
488
489
pub span : SpanData ,
489
- pub id : NodeId ,
490
+ pub id : Id ,
490
491
pub name : String ,
491
492
pub qualname : String ,
492
493
pub type_value : String ,
493
494
pub value : String ,
494
- pub scope : NodeId ,
495
+ pub scope : Id ,
495
496
}
496
497
497
498
impl Lower for data:: TupleVariantData {
@@ -513,7 +514,7 @@ impl Lower for data::TupleVariantData {
513
514
/// Data for a typedef.
514
515
#[ derive( Debug , RustcEncodable ) ]
515
516
pub struct TypedefData {
516
- pub id : NodeId ,
517
+ pub id : Id ,
517
518
pub span : SpanData ,
518
519
pub qualname : String ,
519
520
pub value : String ,
@@ -536,8 +537,8 @@ impl Lower for data::TypedefData {
536
537
#[ derive( Clone , Debug , RustcEncodable ) ]
537
538
pub struct TypeRefData {
538
539
pub span : SpanData ,
539
- pub scope : NodeId ,
540
- pub ref_id : Option < DefId > ,
540
+ pub scope : Id ,
541
+ pub ref_id : Option < Id > ,
541
542
pub qualname : String ,
542
543
}
543
544
@@ -548,19 +549,19 @@ impl Lower for data::TypeRefData {
548
549
TypeRefData {
549
550
span : SpanData :: from_span ( self . span , cm) ,
550
551
scope : self . scope ,
551
- ref_id : self . ref_id ,
552
+ ref_id : self . ref_id . map ( |id| id . index . as_u32 ( ) ) ,
552
553
qualname : self . qualname ,
553
554
}
554
555
}
555
556
}
556
557
557
558
#[ derive( Debug , RustcEncodable ) ]
558
559
pub struct UseData {
559
- pub id : NodeId ,
560
+ pub id : Id ,
560
561
pub span : SpanData ,
561
562
pub name : String ,
562
- pub mod_id : Option < DefId > ,
563
- pub scope : NodeId
563
+ pub mod_id : Option < Id > ,
564
+ pub scope : Id
564
565
}
565
566
566
567
impl Lower for data:: UseData {
@@ -571,18 +572,18 @@ impl Lower for data::UseData {
571
572
id : self . id ,
572
573
span : SpanData :: from_span ( self . span , cm) ,
573
574
name : self . name ,
574
- mod_id : self . mod_id ,
575
+ mod_id : self . mod_id . map ( |id| id . index . as_u32 ( ) ) ,
575
576
scope : self . scope ,
576
577
}
577
578
}
578
579
}
579
580
580
581
#[ derive( Debug , RustcEncodable ) ]
581
582
pub struct UseGlobData {
582
- pub id : NodeId ,
583
+ pub id : Id ,
583
584
pub span : SpanData ,
584
585
pub names : Vec < String > ,
585
- pub scope : NodeId
586
+ pub scope : Id
586
587
}
587
588
588
589
impl Lower for data:: UseGlobData {
@@ -601,11 +602,11 @@ impl Lower for data::UseGlobData {
601
602
/// Data for local and global variables (consts and statics).
602
603
#[ derive( Debug , RustcEncodable ) ]
603
604
pub struct VariableData {
604
- pub id : NodeId ,
605
+ pub id : Id ,
605
606
pub name : String ,
606
607
pub qualname : String ,
607
608
pub span : SpanData ,
608
- pub scope : NodeId ,
609
+ pub scope : Id ,
609
610
pub value : String ,
610
611
pub type_value : String ,
611
612
}
@@ -632,8 +633,8 @@ impl Lower for data::VariableData {
632
633
pub struct VariableRefData {
633
634
pub name : String ,
634
635
pub span : SpanData ,
635
- pub scope : NodeId ,
636
- pub ref_id : DefId ,
636
+ pub scope : Id ,
637
+ pub ref_id : Id ,
637
638
}
638
639
639
640
impl Lower for data:: VariableRefData {
@@ -644,7 +645,7 @@ impl Lower for data::VariableRefData {
644
645
name : self . name ,
645
646
span : SpanData :: from_span ( self . span , cm) ,
646
647
scope : self . scope ,
647
- ref_id : self . ref_id ,
648
+ ref_id : self . ref_id . index . as_u32 ( ) ,
648
649
}
649
650
}
650
651
}
0 commit comments