@@ -244,27 +244,27 @@ impl<'tcx> ImplOrTraitItem<'tcx> {
244
244
match node. span ( ) {
245
245
Some ( span) => match tcx. sess . codemap ( ) . span_to_oneline_snippet ( span) {
246
246
Ok ( snippet) => snippet,
247
- Err ( _) => item. signature ( ) ,
247
+ Err ( _) => item. signature ( tcx ) ,
248
248
} ,
249
- None => item. signature ( ) ,
249
+ None => item. signature ( tcx ) ,
250
250
}
251
251
}
252
- None => item. signature ( ) ,
252
+ None => item. signature ( tcx ) ,
253
253
}
254
254
}
255
- TypeTraitItem ( ref item) => item. signature ( ) ,
255
+ TypeTraitItem ( ref item) => item. signature ( tcx ) ,
256
256
ConstTraitItem ( ref item) => {
257
257
match tcx. map . get_if_local ( item. def_id ) {
258
258
Some ( node) => {
259
259
match node. span ( ) {
260
260
Some ( span) => match tcx. sess . codemap ( ) . span_to_oneline_snippet ( span) {
261
261
Ok ( snippet) => snippet,
262
- Err ( _) => item. signature ( ) ,
262
+ Err ( _) => item. signature ( tcx ) ,
263
263
} ,
264
- None => item. signature ( ) ,
264
+ None => item. signature ( tcx ) ,
265
265
}
266
266
}
267
- None => item. signature ( ) ,
267
+ None => item. signature ( tcx ) ,
268
268
}
269
269
}
270
270
}
@@ -362,7 +362,7 @@ impl<'tcx> Method<'tcx> {
362
362
}
363
363
}
364
364
365
- pub fn signature ( & self ) -> String {
365
+ pub fn signature < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> String {
366
366
let name = self . name . to_string ( ) ;
367
367
let unsafety = match self . fty . unsafety {
368
368
hir:: Unsafety :: Unsafe => "unsafe " ,
@@ -379,6 +379,7 @@ impl<'tcx> Method<'tcx> {
379
379
} ;
380
380
let args = self . fty . sig . inputs ( ) . 0 . iter ( )
381
381
. map ( |t| format ! ( "{:?}" , t) ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
382
+ //let return_type = format!("{}", tcx.item_name(self.fty.sig.output().0.def_id).as_str());
382
383
let return_type = format ! ( "{:?}" , self . fty. sig. output( ) . 0 ) ;
383
384
let return_signature = if & return_type == "()" {
384
385
"" . to_string ( )
@@ -387,7 +388,8 @@ impl<'tcx> Method<'tcx> {
387
388
} ;
388
389
389
390
// unsafe fn name<'a, T>(args) -> ReturnType
390
- format ! ( "{}fn {}{}({}){};" , unsafety, name, type_args, args, return_signature)
391
+ //format!("{}fn {}{}({}){};", unsafety, name, type_args, args, return_signature)
392
+ format ! ( "{}fn {}" , unsafety, self . fty. sig. 0 ) //name, type_args, args, return_signature)
391
393
}
392
394
}
393
395
@@ -417,13 +419,14 @@ pub struct AssociatedConst<'tcx> {
417
419
}
418
420
419
421
impl < ' tcx > AssociatedConst < ' tcx > {
420
- pub fn signature ( & self ) -> String {
422
+ pub fn signature < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> String {
421
423
// const FOO: Type = DEFAULT;
422
424
let value = if self . has_value {
423
425
" = <DEFAULT>"
424
426
} else {
425
427
""
426
428
} ;
429
+ //format!("const {}: {}{};", self.name.to_string(), tcx.item_name(self.ty.def_id).as_str(), value)
427
430
format ! ( "const {}: {:?}{};" , self . name. to_string( ) , self . ty, value)
428
431
}
429
432
}
@@ -439,7 +442,7 @@ pub struct AssociatedType<'tcx> {
439
442
}
440
443
441
444
impl < ' tcx > AssociatedType < ' tcx > {
442
- pub fn signature ( & self ) -> String {
445
+ pub fn signature < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> String {
443
446
//// type Type;
444
447
format ! ( "type {};" , self . name. to_string( ) )
445
448
}
0 commit comments