@@ -139,11 +139,21 @@ fn encode_item_variances(rbml_w: &mut Encoder,
139
139
rbml_w. end_tag ( ) ;
140
140
}
141
141
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
+
142
151
fn encode_bounds_and_type < ' a , ' tcx > ( rbml_w : & mut Encoder ,
143
152
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 ) ;
147
157
}
148
158
149
159
fn encode_variant_id ( rbml_w : & mut Encoder , vid : DefId ) {
@@ -353,8 +363,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
353
363
encode_disr_val ( ecx, rbml_w, ( * vi) [ i] . disr_val ) ;
354
364
disr_val = ( * vi) [ i] . disr_val ;
355
365
}
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 ( ) ) ;
358
367
359
368
ecx. tcx . map . with_path ( variant. node . id , |path| encode_path ( rbml_w, path) ) ;
360
369
rbml_w. end_tag ( ) ;
@@ -698,8 +707,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
698
707
token:: get_name( nm) , id) ;
699
708
encode_struct_field_family ( rbml_w, field. vis ) ;
700
709
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) ;
703
711
encode_def_id ( rbml_w, local_def ( id) ) ;
704
712
705
713
let stab = stability:: lookup ( ecx. tcx , field. id ) ;
@@ -724,8 +732,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
724
732
rbml_w. start_tag ( tag_items_data_item) ;
725
733
encode_def_id ( rbml_w, local_def ( ctor_id) ) ;
726
734
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) ;
729
736
encode_name ( rbml_w, name. name ) ;
730
737
ecx. tcx . map . with_path ( ctor_id, |path| encode_path ( rbml_w, path) ) ;
731
738
encode_parent_item ( rbml_w, local_def ( struct_id) ) ;
@@ -749,6 +756,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
749
756
fn encode_generics < ' a , ' tcx > ( rbml_w : & mut Encoder ,
750
757
ecx : & EncodeContext < ' a , ' tcx > ,
751
758
generics : & ty:: Generics < ' tcx > ,
759
+ predicates : & ty:: GenericPredicates < ' tcx > ,
752
760
tag : uint )
753
761
{
754
762
rbml_w. start_tag ( tag) ;
@@ -790,7 +798,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
790
798
rbml_w. end_tag ( ) ;
791
799
}
792
800
793
- for ( space, _, predicate) in generics . predicates . iter_enumerated ( ) {
801
+ for ( space, _, predicate) in predicates . predicates . iter_enumerated ( ) {
794
802
rbml_w. start_tag ( tag_predicate) ;
795
803
796
804
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>,
810
818
method_ty : & ty:: Method < ' tcx > ) {
811
819
encode_def_id ( rbml_w, method_ty. def_id ) ;
812
820
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 ,
814
822
tag_method_ty_generics) ;
815
823
encode_method_fty ( ecx, rbml_w, & method_ty. fty ) ;
816
824
encode_visibility ( rbml_w, method_ty. vis ) ;
@@ -844,15 +852,15 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
844
852
encode_stability ( rbml_w, stab) ;
845
853
846
854
// 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 ( ) ) ;
849
856
850
857
let elem = ast_map:: PathName ( m. name ) ;
851
858
encode_path ( rbml_w, impl_path. chain ( Some ( elem) . into_iter ( ) ) ) ;
852
859
match ast_item_opt {
853
860
Some ( & ast:: MethodImplItem ( ref ast_method) ) => {
854
861
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 ( ) ;
856
864
if any_types || is_default_impl || should_inline ( & ast_method. attrs [ ] ) {
857
865
encode_inlined_item ( ecx, rbml_w, IIImplItemRef ( local_def ( parent_id) ,
858
866
ast_item_opt. unwrap ( ) ) ) ;
@@ -887,8 +895,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
887
895
encode_parent_item ( rbml_w, local_def ( parent_id) ) ;
888
896
encode_item_sort ( rbml_w, 't' ) ;
889
897
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 ( ) ) ;
892
899
893
900
let stab = stability:: lookup ( ecx. tcx , associated_type. def_id ) ;
894
901
encode_stability ( rbml_w, stab) ;
@@ -1027,7 +1034,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1027
1034
} else {
1028
1035
encode_family ( rbml_w, 'c' ) ;
1029
1036
}
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 ) ;
1031
1038
encode_symbol ( ecx, rbml_w, item. id ) ;
1032
1039
encode_name ( rbml_w, item. ident . name ) ;
1033
1040
encode_path ( rbml_w, path) ;
@@ -1041,7 +1048,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1041
1048
rbml_w. start_tag ( tag_items_data_item) ;
1042
1049
encode_def_id ( rbml_w, def_id) ;
1043
1050
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 ) ;
1045
1052
encode_name ( rbml_w, item. ident . name ) ;
1046
1053
encode_path ( rbml_w, path) ;
1047
1054
encode_attributes ( rbml_w, & item. attrs ) ;
@@ -1056,7 +1063,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1056
1063
encode_def_id ( rbml_w, def_id) ;
1057
1064
encode_family ( rbml_w, FN_FAMILY ) ;
1058
1065
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 ) ;
1060
1067
encode_name ( rbml_w, item. ident . name ) ;
1061
1068
encode_path ( rbml_w, path) ;
1062
1069
encode_attributes ( rbml_w, & item. attrs [ ] ) ;
@@ -1105,7 +1112,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1105
1112
rbml_w. start_tag ( tag_items_data_item) ;
1106
1113
encode_def_id ( rbml_w, def_id) ;
1107
1114
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 ) ;
1109
1116
encode_name ( rbml_w, item. ident . name ) ;
1110
1117
encode_path ( rbml_w, path) ;
1111
1118
encode_visibility ( rbml_w, vis) ;
@@ -1119,7 +1126,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1119
1126
encode_def_id ( rbml_w, def_id) ;
1120
1127
encode_family ( rbml_w, 't' ) ;
1121
1128
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 ) ;
1123
1130
encode_name ( rbml_w, item. ident . name ) ;
1124
1131
encode_attributes ( rbml_w, & item. attrs [ ] ) ;
1125
1132
encode_repr_attrs ( rbml_w, ecx, & item. attrs [ ] ) ;
@@ -1161,7 +1168,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1161
1168
rbml_w. start_tag ( tag_items_data_item) ;
1162
1169
encode_def_id ( rbml_w, def_id) ;
1163
1170
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 ) ;
1165
1172
1166
1173
encode_item_variances ( rbml_w, ecx, item. id ) ;
1167
1174
encode_name ( rbml_w, item. ident . name ) ;
@@ -1204,7 +1211,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1204
1211
rbml_w. start_tag ( tag_items_data_item) ;
1205
1212
encode_def_id ( rbml_w, def_id) ;
1206
1213
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 ) ;
1208
1215
encode_name ( rbml_w, item. ident . name ) ;
1209
1216
encode_attributes ( rbml_w, & item. attrs [ ] ) ;
1210
1217
encode_unsafety ( rbml_w, unsafety) ;
@@ -1305,10 +1312,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
1305
1312
encode_family ( rbml_w, 'I' ) ;
1306
1313
encode_item_variances ( rbml_w, ecx, item. id ) ;
1307
1314
let trait_def = ty:: lookup_trait_def ( tcx, def_id) ;
1315
+ let trait_predicates = ty:: lookup_predicates ( tcx, def_id) ;
1308
1316
encode_unsafety ( rbml_w, trait_def. unsafety ) ;
1309
1317
encode_paren_sugar ( rbml_w, trait_def. paren_sugar ) ;
1310
1318
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) ;
1312
1320
encode_trait_ref ( rbml_w, ecx, & * trait_def. trait_ref , tag_item_trait_ref) ;
1313
1321
encode_name ( rbml_w, item. ident . name ) ;
1314
1322
encode_attributes ( rbml_w, & item. attrs [ ] ) ;
@@ -1384,9 +1392,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1384
1392
METHOD_FAMILY ) ;
1385
1393
}
1386
1394
}
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 ( ) ) ;
1390
1396
1391
1397
is_nonstatic_method = method_ty. explicit_self !=
1392
1398
ty:: StaticExplicitSelfCategory ;
@@ -1415,8 +1421,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1415
1421
if is_nonstatic_method {
1416
1422
// FIXME: I feel like there is something funny
1417
1423
// 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 ( ) ) ;
1420
1425
}
1421
1426
} ;
1422
1427
match trait_item {
@@ -1468,8 +1473,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
1468
1473
match nitem. node {
1469
1474
ast:: ForeignItemFn ( ref fndecl, _) => {
1470
1475
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 ) ;
1473
1477
encode_name ( rbml_w, nitem. ident . name ) ;
1474
1478
if abi == abi:: RustIntrinsic {
1475
1479
encode_inlined_item ( ecx, rbml_w, IIForeignRef ( nitem) ) ;
@@ -1486,8 +1490,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
1486
1490
} else {
1487
1491
encode_family ( rbml_w, 'c' ) ;
1488
1492
}
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 ) ;
1491
1494
encode_attributes ( rbml_w, & * nitem. attrs ) ;
1492
1495
let stab = stability:: lookup ( ecx. tcx , ast_util:: local_def ( nitem. id ) ) ;
1493
1496
encode_stability ( rbml_w, stab) ;
0 commit comments