@@ -34,13 +34,11 @@ use session::Session;
34
34
35
35
use middle:: def;
36
36
use middle:: ty:: { self , Ty } ;
37
- use rustc:: ast_map:: NodeItem ;
38
37
39
38
use std:: cell:: Cell ;
40
39
use std:: fs:: File ;
41
40
use std:: path:: Path ;
42
41
43
- use syntax:: ast_util;
44
42
use syntax:: ast:: { self , NodeId , DefId } ;
45
43
use syntax:: codemap:: * ;
46
44
use syntax:: parse:: token:: { self , get_ident, keywords} ;
@@ -298,101 +296,34 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
298
296
}
299
297
}
300
298
301
- fn process_method ( & mut self , sig : & ast:: MethodSig ,
299
+ fn process_method ( & mut self ,
300
+ sig : & ast:: MethodSig ,
302
301
body : Option < & ast:: Block > ,
303
- id : ast:: NodeId , name : ast:: Name ,
302
+ id : ast:: NodeId ,
303
+ name : ast:: Name ,
304
304
span : Span ) {
305
305
if generated_code ( span) {
306
306
return ;
307
307
}
308
308
309
309
debug ! ( "process_method: {}:{}" , id, token:: get_name( name) ) ;
310
310
311
- let scope_id;
312
- // The qualname for a method is the trait name or name of the struct in an impl in
313
- // which the method is declared in, followed by the method's name.
314
- let qualname = match self . tcx . impl_of_method ( ast_util:: local_def ( id) ) {
315
- Some ( impl_id) => match self . tcx . map . get ( impl_id. node ) {
316
- NodeItem ( item) => {
317
- scope_id = item. id ;
318
- match item. node {
319
- ast:: ItemImpl ( _, _, _, _, ref ty, _) => {
320
- let mut result = String :: from ( "<" ) ;
321
- result. push_str ( & ty_to_string ( & * * ty) ) ;
322
-
323
- match self . tcx . trait_of_item ( ast_util:: local_def ( id) ) {
324
- Some ( def_id) => {
325
- result. push_str ( " as " ) ;
326
- result. push_str (
327
- & self . tcx . item_path_str ( def_id) ) ;
328
- } ,
329
- None => { }
330
- }
331
- result. push_str ( ">" ) ;
332
- result
333
- }
334
- _ => {
335
- self . sess . span_bug ( span,
336
- & format ! ( "Container {} for method {} not an impl?" ,
337
- impl_id. node, id) ) ;
338
- } ,
339
- }
340
- } ,
341
- _ => {
342
- self . sess . span_bug ( span,
343
- & format ! ( "Container {} for method {} is not a node item {:?}" ,
344
- impl_id. node, id, self . tcx. map. get( impl_id. node) ) ) ;
345
- } ,
346
- } ,
347
- None => match self . tcx . trait_of_item ( ast_util:: local_def ( id) ) {
348
- Some ( def_id) => {
349
- scope_id = def_id. node ;
350
- match self . tcx . map . get ( def_id. node ) {
351
- NodeItem ( _) => {
352
- format ! ( "::{}" , self . tcx. item_path_str( def_id) )
353
- }
354
- _ => {
355
- self . sess . span_bug ( span,
356
- & format ! ( "Could not find container {} for method {}" ,
357
- def_id. node, id) ) ;
358
- }
359
- }
360
- } ,
361
- None => {
362
- self . sess . span_bug ( span,
363
- & format ! ( "Could not find container for method {}" , id) ) ;
364
- } ,
365
- } ,
366
- } ;
367
-
368
- let qualname = & format ! ( "{}::{}" , qualname, & token:: get_name( name) ) ;
311
+ let method_data = self . save_ctxt . get_method_data ( id, name, span) ;
369
312
370
- // record the decl for this def (if it has one)
371
- let decl_id = self . tcx . trait_item_of_item ( ast_util:: local_def ( id) )
372
- . and_then ( |new_id| {
373
- let def_id = new_id. def_id ( ) ;
374
- if def_id. node != 0 && def_id != ast_util:: local_def ( id) {
375
- Some ( def_id)
376
- } else {
377
- None
378
- }
379
- } ) ;
380
-
381
- let sub_span = self . span . sub_span_after_keyword ( span, keywords:: Fn ) ;
382
313
if body. is_some ( ) {
383
314
self . fmt . method_str ( span,
384
- sub_span ,
385
- id,
386
- qualname,
387
- decl_id ,
388
- scope_id ) ;
389
- self . process_formals ( & sig. decl . inputs , qualname) ;
315
+ Some ( method_data . span ) ,
316
+ method_data . id ,
317
+ & method_data . qualname ,
318
+ method_data . declaration ,
319
+ method_data . scope ) ;
320
+ self . process_formals ( & sig. decl . inputs , & method_data . qualname ) ;
390
321
} else {
391
322
self . fmt . method_decl_str ( span,
392
- sub_span ,
393
- id,
394
- qualname,
395
- scope_id ) ;
323
+ Some ( method_data . span ) ,
324
+ method_data . id ,
325
+ & method_data . qualname ,
326
+ method_data . scope ) ;
396
327
}
397
328
398
329
// walk arg and return types
@@ -411,7 +342,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
411
342
412
343
self . process_generic_params ( & sig. generics ,
413
344
span,
414
- qualname,
345
+ & method_data . qualname ,
415
346
id) ;
416
347
}
417
348
@@ -432,7 +363,6 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
432
363
parent_id : NodeId ) {
433
364
let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
434
365
if let Some ( field_data) = field_data {
435
- down_cast_data ! ( field_data, VariableData , self , field. span) ;
436
366
self . fmt . field_str ( field. span ,
437
367
Some ( field_data. span ) ,
438
368
field_data. id ,
@@ -1087,8 +1017,11 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1087
1017
trait_item. span , & * ty, & * expr) ;
1088
1018
}
1089
1019
ast:: MethodTraitItem ( ref sig, ref body) => {
1090
- self . process_method ( sig, body. as_ref ( ) . map ( |x| & * * x) ,
1091
- trait_item. id , trait_item. ident . name , trait_item. span ) ;
1020
+ self . process_method ( sig,
1021
+ body. as_ref ( ) . map ( |x| & * * x) ,
1022
+ trait_item. id ,
1023
+ trait_item. ident . name ,
1024
+ trait_item. span ) ;
1092
1025
}
1093
1026
ast:: ConstTraitItem ( _, None ) |
1094
1027
ast:: TypeTraitItem ( ..) => { }
@@ -1102,8 +1035,11 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
1102
1035
impl_item. span , & ty, & expr) ;
1103
1036
}
1104
1037
ast:: MethodImplItem ( ref sig, ref body) => {
1105
- self . process_method ( sig, Some ( body) , impl_item. id ,
1106
- impl_item. ident . name , impl_item. span ) ;
1038
+ self . process_method ( sig,
1039
+ Some ( body) ,
1040
+ impl_item. id ,
1041
+ impl_item. ident . name ,
1042
+ impl_item. span ) ;
1107
1043
}
1108
1044
ast:: TypeImplItem ( _) |
1109
1045
ast:: MacImplItem ( _) => { }
0 commit comments