@@ -139,11 +139,21 @@ fn encode_item_variances(rbml_w: &mut Encoder,
139139 rbml_w. end_tag ( ) ;
140140}
141141
142+ fn encode_bounds_and_type_for_item < ' a , ' tcx > ( rbml_w : & mut Encoder ,
143+ ecx : & EncodeContext < ' a , ' tcx > ,
144+ id : ast:: NodeId ) {
145+ encode_bounds_and_type ( rbml_w,
146+ ecx,
147+ & ty:: lookup_item_type ( ecx. tcx , local_def ( id) ) ,
148+ & ty:: lookup_predicates ( ecx. tcx , local_def ( id) ) ) ;
149+ }
150+
142151fn encode_bounds_and_type < ' a , ' tcx > ( rbml_w : & mut Encoder ,
143152 ecx : & EncodeContext < ' a , ' tcx > ,
144- pty : & ty:: TypeScheme < ' tcx > ) {
145- encode_generics ( rbml_w, ecx, & pty. generics , tag_item_generics) ;
146- encode_type ( ecx, rbml_w, pty. ty ) ;
153+ scheme : & ty:: TypeScheme < ' tcx > ,
154+ predicates : & ty:: GenericPredicates < ' tcx > ) {
155+ encode_generics ( rbml_w, ecx, & scheme. generics , & predicates, tag_item_generics) ;
156+ encode_type ( ecx, rbml_w, scheme. ty ) ;
147157}
148158
149159fn encode_variant_id ( rbml_w : & mut Encoder , vid : DefId ) {
@@ -353,8 +363,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
353363 encode_disr_val ( ecx, rbml_w, ( * vi) [ i] . disr_val ) ;
354364 disr_val = ( * vi) [ i] . disr_val ;
355365 }
356- encode_bounds_and_type ( rbml_w, ecx,
357- & lookup_item_type ( ecx. tcx , def_id) ) ;
366+ encode_bounds_and_type_for_item ( rbml_w, ecx, def_id. local_id ( ) ) ;
358367
359368 ecx. tcx . map . with_path ( variant. node . id , |path| encode_path ( rbml_w, path) ) ;
360369 rbml_w. end_tag ( ) ;
@@ -698,8 +707,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
698707 token:: get_name( nm) , id) ;
699708 encode_struct_field_family ( rbml_w, field. vis ) ;
700709 encode_name ( rbml_w, nm) ;
701- encode_bounds_and_type ( rbml_w, ecx,
702- & lookup_item_type ( ecx. tcx , local_def ( id) ) ) ;
710+ encode_bounds_and_type_for_item ( rbml_w, ecx, id) ;
703711 encode_def_id ( rbml_w, local_def ( id) ) ;
704712
705713 let stab = stability:: lookup ( ecx. tcx , field. id ) ;
@@ -724,8 +732,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
724732 rbml_w. start_tag ( tag_items_data_item) ;
725733 encode_def_id ( rbml_w, local_def ( ctor_id) ) ;
726734 encode_family ( rbml_w, 'o' ) ;
727- encode_bounds_and_type ( rbml_w, ecx,
728- & lookup_item_type ( ecx. tcx , local_def ( ctor_id) ) ) ;
735+ encode_bounds_and_type_for_item ( rbml_w, ecx, ctor_id) ;
729736 encode_name ( rbml_w, name. name ) ;
730737 ecx. tcx . map . with_path ( ctor_id, |path| encode_path ( rbml_w, path) ) ;
731738 encode_parent_item ( rbml_w, local_def ( struct_id) ) ;
@@ -749,6 +756,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
749756fn encode_generics < ' a , ' tcx > ( rbml_w : & mut Encoder ,
750757 ecx : & EncodeContext < ' a , ' tcx > ,
751758 generics : & ty:: Generics < ' tcx > ,
759+ predicates : & ty:: GenericPredicates < ' tcx > ,
752760 tag : uint )
753761{
754762 rbml_w. start_tag ( tag) ;
@@ -790,7 +798,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
790798 rbml_w. end_tag ( ) ;
791799 }
792800
793- for ( space, _, predicate) in generics . predicates . iter_enumerated ( ) {
801+ for ( space, _, predicate) in predicates . predicates . iter_enumerated ( ) {
794802 rbml_w. start_tag ( tag_predicate) ;
795803
796804 rbml_w. wr_tagged_u8 ( tag_predicate_space, space as u8 ) ;
@@ -810,7 +818,7 @@ fn encode_method_ty_fields<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
810818 method_ty : & ty:: Method < ' tcx > ) {
811819 encode_def_id ( rbml_w, method_ty. def_id ) ;
812820 encode_name ( rbml_w, method_ty. name ) ;
813- encode_generics ( rbml_w, ecx, & method_ty. generics ,
821+ encode_generics ( rbml_w, ecx, & method_ty. generics , & method_ty . predicates ,
814822 tag_method_ty_generics) ;
815823 encode_method_fty ( ecx, rbml_w, & method_ty. fty ) ;
816824 encode_visibility ( rbml_w, method_ty. vis ) ;
@@ -844,15 +852,15 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
844852 encode_stability ( rbml_w, stab) ;
845853
846854 // The type for methods gets encoded twice, which is unfortunate.
847- let pty = lookup_item_type ( ecx. tcx , m. def_id ) ;
848- encode_bounds_and_type ( rbml_w, ecx, & pty) ;
855+ encode_bounds_and_type_for_item ( rbml_w, ecx, m. def_id . local_id ( ) ) ;
849856
850857 let elem = ast_map:: PathName ( m. name ) ;
851858 encode_path ( rbml_w, impl_path. chain ( Some ( elem) . into_iter ( ) ) ) ;
852859 match ast_item_opt {
853860 Some ( & ast:: MethodImplItem ( ref ast_method) ) => {
854861 encode_attributes ( rbml_w, & ast_method. attrs [ ] ) ;
855- let any_types = !pty. generics . types . is_empty ( ) ;
862+ let scheme = ty:: lookup_item_type ( ecx. tcx , m. def_id ) ;
863+ let any_types = !scheme. generics . types . is_empty ( ) ;
856864 if any_types || is_default_impl || should_inline ( & ast_method. attrs [ ] ) {
857865 encode_inlined_item ( ecx, rbml_w, IIImplItemRef ( local_def ( parent_id) ,
858866 ast_item_opt. unwrap ( ) ) ) ;
@@ -887,8 +895,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
887895 encode_parent_item ( rbml_w, local_def ( parent_id) ) ;
888896 encode_item_sort ( rbml_w, 't' ) ;
889897
890- let type_scheme = ty:: lookup_item_type ( ecx. tcx , associated_type. def_id ) ;
891- encode_bounds_and_type ( rbml_w, ecx, & type_scheme) ;
898+ encode_bounds_and_type_for_item ( rbml_w, ecx, associated_type. def_id . local_id ( ) ) ;
892899
893900 let stab = stability:: lookup ( ecx. tcx , associated_type. def_id ) ;
894901 encode_stability ( rbml_w, stab) ;
@@ -1027,7 +1034,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
10271034 } else {
10281035 encode_family ( rbml_w, 'c' ) ;
10291036 }
1030- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1037+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
10311038 encode_symbol ( ecx, rbml_w, item. id ) ;
10321039 encode_name ( rbml_w, item. ident . name ) ;
10331040 encode_path ( rbml_w, path) ;
@@ -1041,7 +1048,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
10411048 rbml_w. start_tag ( tag_items_data_item) ;
10421049 encode_def_id ( rbml_w, def_id) ;
10431050 encode_family ( rbml_w, 'C' ) ;
1044- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1051+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
10451052 encode_name ( rbml_w, item. ident . name ) ;
10461053 encode_path ( rbml_w, path) ;
10471054 encode_attributes ( rbml_w, & item. attrs ) ;
@@ -1056,7 +1063,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
10561063 encode_def_id ( rbml_w, def_id) ;
10571064 encode_family ( rbml_w, FN_FAMILY ) ;
10581065 let tps_len = generics. ty_params . len ( ) ;
1059- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1066+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
10601067 encode_name ( rbml_w, item. ident . name ) ;
10611068 encode_path ( rbml_w, path) ;
10621069 encode_attributes ( rbml_w, & item. attrs [ ] ) ;
@@ -1105,7 +1112,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
11051112 rbml_w. start_tag ( tag_items_data_item) ;
11061113 encode_def_id ( rbml_w, def_id) ;
11071114 encode_family ( rbml_w, 'y' ) ;
1108- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1115+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
11091116 encode_name ( rbml_w, item. ident . name ) ;
11101117 encode_path ( rbml_w, path) ;
11111118 encode_visibility ( rbml_w, vis) ;
@@ -1119,7 +1126,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
11191126 encode_def_id ( rbml_w, def_id) ;
11201127 encode_family ( rbml_w, 't' ) ;
11211128 encode_item_variances ( rbml_w, ecx, item. id ) ;
1122- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1129+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
11231130 encode_name ( rbml_w, item. ident . name ) ;
11241131 encode_attributes ( rbml_w, & item. attrs [ ] ) ;
11251132 encode_repr_attrs ( rbml_w, ecx, & item. attrs [ ] ) ;
@@ -1161,7 +1168,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
11611168 rbml_w. start_tag ( tag_items_data_item) ;
11621169 encode_def_id ( rbml_w, def_id) ;
11631170 encode_family ( rbml_w, 'S' ) ;
1164- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1171+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
11651172
11661173 encode_item_variances ( rbml_w, ecx, item. id ) ;
11671174 encode_name ( rbml_w, item. ident . name ) ;
@@ -1204,7 +1211,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
12041211 rbml_w. start_tag ( tag_items_data_item) ;
12051212 encode_def_id ( rbml_w, def_id) ;
12061213 encode_family ( rbml_w, 'i' ) ;
1207- encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx , def_id ) ) ;
1214+ encode_bounds_and_type_for_item ( rbml_w, ecx, item . id ) ;
12081215 encode_name ( rbml_w, item. ident . name ) ;
12091216 encode_attributes ( rbml_w, & item. attrs [ ] ) ;
12101217 encode_unsafety ( rbml_w, unsafety) ;
@@ -1305,10 +1312,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
13051312 encode_family ( rbml_w, 'I' ) ;
13061313 encode_item_variances ( rbml_w, ecx, item. id ) ;
13071314 let trait_def = ty:: lookup_trait_def ( tcx, def_id) ;
1315+ let trait_predicates = ty:: lookup_predicates ( tcx, def_id) ;
13081316 encode_unsafety ( rbml_w, trait_def. unsafety ) ;
13091317 encode_paren_sugar ( rbml_w, trait_def. paren_sugar ) ;
13101318 encode_associated_type_names ( rbml_w, & trait_def. associated_type_names ) ;
1311- encode_generics ( rbml_w, ecx, & trait_def. generics , tag_item_generics) ;
1319+ encode_generics ( rbml_w, ecx, & trait_def. generics , & trait_predicates , tag_item_generics) ;
13121320 encode_trait_ref ( rbml_w, ecx, & * trait_def. trait_ref , tag_item_trait_ref) ;
13131321 encode_name ( rbml_w, item. ident . name ) ;
13141322 encode_attributes ( rbml_w, & item. attrs [ ] ) ;
@@ -1384,9 +1392,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
13841392 METHOD_FAMILY ) ;
13851393 }
13861394 }
1387- let pty = ty:: lookup_item_type ( tcx,
1388- method_def_id) ;
1389- encode_bounds_and_type ( rbml_w, ecx, & pty) ;
1395+ encode_bounds_and_type_for_item ( rbml_w, ecx, method_def_id. local_id ( ) ) ;
13901396
13911397 is_nonstatic_method = method_ty. explicit_self !=
13921398 ty:: StaticExplicitSelfCategory ;
@@ -1415,8 +1421,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
14151421 if is_nonstatic_method {
14161422 // FIXME: I feel like there is something funny
14171423 // going on.
1418- let pty = ty:: lookup_item_type ( tcx, item_def_id. def_id ( ) ) ;
1419- encode_bounds_and_type ( rbml_w, ecx, & pty) ;
1424+ encode_bounds_and_type_for_item ( rbml_w, ecx, item_def_id. def_id ( ) . local_id ( ) ) ;
14201425 }
14211426 } ;
14221427 match trait_item {
@@ -1468,8 +1473,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
14681473 match nitem. node {
14691474 ast:: ForeignItemFn ( ref fndecl, _) => {
14701475 encode_family ( rbml_w, FN_FAMILY ) ;
1471- encode_bounds_and_type ( rbml_w, ecx,
1472- & lookup_item_type ( ecx. tcx , local_def ( nitem. id ) ) ) ;
1476+ encode_bounds_and_type_for_item ( rbml_w, ecx, nitem. id ) ;
14731477 encode_name ( rbml_w, nitem. ident . name ) ;
14741478 if abi == abi:: RustIntrinsic {
14751479 encode_inlined_item ( ecx, rbml_w, IIForeignRef ( nitem) ) ;
@@ -1486,8 +1490,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
14861490 } else {
14871491 encode_family ( rbml_w, 'c' ) ;
14881492 }
1489- encode_bounds_and_type ( rbml_w, ecx,
1490- & lookup_item_type ( ecx. tcx , local_def ( nitem. id ) ) ) ;
1493+ encode_bounds_and_type_for_item ( rbml_w, ecx, nitem. id ) ;
14911494 encode_attributes ( rbml_w, & * nitem. attrs ) ;
14921495 let stab = stability:: lookup ( ecx. tcx , ast_util:: local_def ( nitem. id ) ) ;
14931496 encode_stability ( rbml_w, stab) ;
0 commit comments