@@ -722,18 +722,35 @@ impl Clean<FnDecl> for ast::FnDecl {
722
722
}
723
723
}
724
724
725
- impl Clean < FnDecl > for ty:: FnSig {
725
+ impl < ' a > Clean < FnDecl > for ( ast :: DefId , & ' a ty:: FnSig ) {
726
726
fn clean ( & self ) -> FnDecl {
727
+ let cx = super :: ctxtkey. get ( ) . unwrap ( ) ;
728
+ let tcx = match cx. maybe_typed {
729
+ core:: Typed ( ref tcx) => tcx,
730
+ core:: NotTyped ( _) => fail ! ( ) ,
731
+ } ;
732
+ let ( did, sig) = * self ;
733
+ let mut names = if did. node != 0 {
734
+ csearch:: get_method_arg_names ( & tcx. sess . cstore , did) . move_iter ( )
735
+ } else {
736
+ Vec :: new ( ) . move_iter ( )
737
+ } . peekable ( ) ;
738
+ if names. peek ( ) . map ( |s| s. as_slice ( ) ) == Some ( "self" ) {
739
+ let _ = names. next ( ) ;
740
+ }
741
+ if did. node == 0 {
742
+ let _ = names. len ( ) ;
743
+ }
727
744
FnDecl {
728
- output : self . output . clean ( ) ,
745
+ output : sig . output . clean ( ) ,
729
746
cf : Return ,
730
- attrs : Vec :: new ( ) , // FIXME: this is likely wrong
747
+ attrs : Vec :: new ( ) ,
731
748
inputs : Arguments {
732
- values : self . inputs . iter ( ) . map ( |t| {
749
+ values : sig . inputs . iter ( ) . map ( |t| {
733
750
Argument {
734
751
type_ : t. clean ( ) ,
735
752
id : 0 ,
736
- name : "" . to_strbuf ( ) , // FIXME: where are the names?
753
+ name : names . next ( ) . unwrap_or ( "" . to_strbuf ( ) ) ,
737
754
}
738
755
} ) . collect ( ) ,
739
756
} ,
@@ -868,15 +885,6 @@ impl Clean<TraitMethod> for ty::Method {
868
885
( s, sig)
869
886
}
870
887
} ;
871
- let mut names = csearch:: get_method_arg_names ( & tcx. sess . cstore ,
872
- self . def_id ) . move_iter ( ) ;
873
- if self_ != SelfStatic {
874
- names. next ( ) ;
875
- }
876
- let mut decl = sig. clean ( ) ;
877
- for ( name, slot) in names. zip ( decl. inputs . values . mut_iter ( ) ) {
878
- slot. name = name;
879
- }
880
888
881
889
m ( Item {
882
890
name : Some ( self . ident . clean ( ) ) ,
@@ -888,7 +896,7 @@ impl Clean<TraitMethod> for ty::Method {
888
896
fn_style : self . fty . fn_style ,
889
897
generics : self . generics . clean ( ) ,
890
898
self_ : self_,
891
- decl : decl ,
899
+ decl : ( self . def_id , & sig ) . clean ( ) ,
892
900
} )
893
901
} )
894
902
}
@@ -1005,13 +1013,13 @@ impl Clean<Type> for ty::t {
1005
1013
generics : Generics {
1006
1014
lifetimes : Vec :: new ( ) , type_params : Vec :: new ( )
1007
1015
} ,
1008
- decl : fty. sig . clean ( ) ,
1016
+ decl : ( ast_util :: local_def ( 0 ) , & fty. sig ) . clean ( ) ,
1009
1017
abi : fty. abi . to_str ( ) . to_strbuf ( ) ,
1010
1018
} ) ,
1011
1019
ty:: ty_closure( ref fty) => {
1012
1020
let decl = box ClosureDecl {
1013
1021
lifetimes : Vec :: new ( ) , // FIXME: this looks wrong...
1014
- decl : fty. sig . clean ( ) ,
1022
+ decl : ( ast_util :: local_def ( 0 ) , & fty. sig ) . clean ( ) ,
1015
1023
onceness : fty. onceness ,
1016
1024
fn_style : fty. fn_style ,
1017
1025
bounds : fty. bounds . iter ( ) . map ( |i| i. clean ( ) ) . collect ( ) ,
@@ -1855,7 +1863,7 @@ fn build_external_function(tcx: &ty::ctxt,
1855
1863
let t = ty:: lookup_item_type ( tcx, did) ;
1856
1864
Function {
1857
1865
decl : match ty:: get ( t. ty ) . sty {
1858
- ty:: ty_bare_fn( ref f) => f. sig . clean ( ) ,
1866
+ ty:: ty_bare_fn( ref f) => ( did , & f. sig ) . clean ( ) ,
1859
1867
_ => fail ! ( "bad function" ) ,
1860
1868
} ,
1861
1869
generics : t. generics . clean ( ) ,
0 commit comments