@@ -650,6 +650,16 @@ fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) {
650650 ebml_w. end_tag ( ) ;
651651}
652652
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+
653663/* Returns an index of items in this class */
654664fn encode_info_for_struct ( ecx : & EncodeContext ,
655665 ebml_w : & mut writer:: Encoder ,
@@ -726,6 +736,7 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
726736 }
727737 _ => encode_family ( ebml_w, purity_fn_family ( purity) )
728738 }
739+ encode_provided_source ( ebml_w, method_ty. provided_source ) ;
729740}
730741
731742fn encode_info_for_method ( ecx : & EncodeContext ,
@@ -987,7 +998,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
987998 _ => { }
988999 }
9891000 for imp. methods. iter( ) . advance |method| {
990- if method. provided_source. is_some ( ) { loop; }
9911001 ebml_w. start_tag( tag_item_impl_method) ;
9921002 let s = def_to_str( method. def_id) ;
9931003 ebml_w. writer. write( s. as_bytes( ) ) ;
@@ -1005,16 +1015,24 @@ fn encode_info_for_item(ecx: &EncodeContext,
10051015 let mut impl_path = vec:: append( ~[ ] , path) ;
10061016 impl_path. push( ast_map:: path_name( item. ident) ) ;
10071017
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+
10101028 index. push ( entry { val : m. def_id. node, pos : ebml_w. writer. tell( ) } ) ;
10111029 encode_info_for_method ( ecx ,
10121030 ebml_w ,
1013- m,
1031+ * m ,
10141032 impl_path ,
10151033 false ,
10161034 item. id ,
1017- Some ( * ast_method) ) ;
1035+ ast_method )
10181036 }
10191037 }
10201038 item_trait( _, ref super_traits, ref ms) => {
0 commit comments