@@ -650,6 +650,16 @@ fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) {
650
650
ebml_w. end_tag ( ) ;
651
651
}
652
652
653
+ fn encode_provided_source ( ebml_w : & mut writer:: Encoder ,
654
+ source_opt : Option < def_id > ) {
655
+ for source_opt. iter( ) . advance |source| {
656
+ ebml_w. start_tag( tag_item_method_provided_source) ;
657
+ let s = def_to_str ( * source) ;
658
+ ebml_w. writer . write ( s. as_bytes ( ) ) ;
659
+ ebml_w. end_tag ( ) ;
660
+ }
661
+ }
662
+
653
663
/* Returns an index of items in this class */
654
664
fn encode_info_for_struct ( ecx : & EncodeContext ,
655
665
ebml_w : & mut writer:: Encoder ,
@@ -726,6 +736,7 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
726
736
}
727
737
_ => encode_family ( ebml_w, purity_fn_family ( purity) )
728
738
}
739
+ encode_provided_source ( ebml_w, method_ty. provided_source ) ;
729
740
}
730
741
731
742
fn encode_info_for_method ( ecx : & EncodeContext ,
@@ -987,7 +998,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
987
998
_ => { }
988
999
}
989
1000
for imp. methods. iter( ) . advance |method| {
990
- if method. provided_source. is_some ( ) { loop; }
991
1001
ebml_w. start_tag( tag_item_impl_method) ;
992
1002
let s = def_to_str( method. def_id) ;
993
1003
ebml_w. writer. write( s. as_bytes( ) ) ;
@@ -1005,16 +1015,24 @@ fn encode_info_for_item(ecx: &EncodeContext,
1005
1015
let mut impl_path = vec:: append( ~[ ] , path) ;
1006
1016
impl_path. push( ast_map:: path_name( item. ident) ) ;
1007
1017
1008
- for ast_methods. iter( ) . advance |ast_method| {
1009
- let m = ty:: method( ecx. tcx, local_def( ast_method. id) ) ;
1018
+ // Iterate down the methods, emitting them. We rely on the
1019
+ // assumption that all of the actually implemented methods
1020
+ // appear first in the impl structure, in the same order they do
1021
+ // in the ast. This is a little sketchy.
1022
+ let num_implemented_methods = ast_methods. len( ) ;
1023
+ for imp. methods. iter( ) . enumerate( ) . advance |( i, m) | {
1024
+ let ast_method = if i < num_implemented_methods {
1025
+ Some ( ast_methods[ i] )
1026
+ } else { None } ;
1027
+
1010
1028
index. push ( entry { val : m. def_id. node, pos : ebml_w. writer. tell( ) } ) ;
1011
1029
encode_info_for_method ( ecx ,
1012
1030
ebml_w ,
1013
- m,
1031
+ * m ,
1014
1032
impl_path ,
1015
1033
false ,
1016
1034
item. id ,
1017
- Some ( * ast_method) ) ;
1035
+ ast_method )
1018
1036
}
1019
1037
}
1020
1038
item_trait( _, ref super_traits, ref ms) => {
0 commit comments