@@ -172,16 +172,13 @@ fn item_visibility(item: rbml::Doc) -> ast::Visibility {
172
172
}
173
173
}
174
174
175
- fn item_sort ( item : rbml:: Doc ) -> char {
175
+ fn item_sort ( item : rbml:: Doc ) -> Option < char > {
176
176
let mut ret = None ;
177
177
reader:: tagged_docs ( item, tag_item_trait_item_sort, |doc| {
178
178
ret = Some ( doc. as_str_slice ( ) . as_bytes ( ) [ 0 ] as char ) ;
179
179
false
180
180
} ) ;
181
- match ret {
182
- Some ( r) => r,
183
- None => panic ! ( "No item_sort found" )
184
- }
181
+ ret
185
182
}
186
183
187
184
fn item_symbol ( item : rbml:: Doc ) -> String {
@@ -344,7 +341,14 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
344
341
_ => panic ! ( )
345
342
}
346
343
}
347
- Type => DlDef ( def:: DefTy ( did, false ) ) ,
344
+ Type => {
345
+ if item_sort ( item) == Some ( 't' ) {
346
+ let trait_did = item_reqd_and_translated_parent_item ( cnum, item) ;
347
+ DlDef ( def:: DefAssociatedTy ( trait_did, did) )
348
+ } else {
349
+ DlDef ( def:: DefTy ( did, false ) )
350
+ }
351
+ }
348
352
Mod => DlDef ( def:: DefMod ( did) ) ,
349
353
ForeignMod => DlDef ( def:: DefForeignMod ( did) ) ,
350
354
StructVariant => {
@@ -829,8 +833,10 @@ pub fn get_impl_items(cdata: Cmd, impl_id: ast::NodeId)
829
833
tag_item_impl_item, |doc| {
830
834
let def_id = item_def_id ( doc, cdata) ;
831
835
match item_sort ( doc) {
832
- 'r' | 'p' => impl_items. push ( ty:: MethodTraitItemId ( def_id) ) ,
833
- 't' => impl_items. push ( ty:: TypeTraitItemId ( def_id) ) ,
836
+ Some ( 'r' ) | Some ( 'p' ) => {
837
+ impl_items. push ( ty:: MethodTraitItemId ( def_id) )
838
+ }
839
+ Some ( 't' ) => impl_items. push ( ty:: TypeTraitItemId ( def_id) ) ,
834
840
_ => panic ! ( "unknown impl item sort" ) ,
835
841
}
836
842
true
@@ -854,14 +860,14 @@ pub fn get_trait_item_name_and_kind(intr: Rc<IdentInterner>,
854
860
let doc = lookup_item ( id, cdata. data ( ) ) ;
855
861
let name = item_name ( & * intr, doc) ;
856
862
match item_sort ( doc) {
857
- 'r' | 'p' => {
863
+ Some ( 'r' ) | Some ( 'p' ) => {
858
864
let explicit_self = get_explicit_self ( doc) ;
859
865
( name, def:: TraitItemKind :: from_explicit_self_category ( explicit_self) )
860
866
}
861
- 't' => ( name, def:: TypeTraitItemKind ) ,
867
+ Some ( 't' ) => ( name, def:: TypeTraitItemKind ) ,
862
868
c => {
863
869
panic ! ( "get_trait_item_name_and_kind(): unknown trait item kind \
864
- in metadata: `{}`", c)
870
+ in metadata: `{:? }`", c)
865
871
}
866
872
}
867
873
}
@@ -887,7 +893,7 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
887
893
let vis = item_visibility ( method_doc) ;
888
894
889
895
match item_sort ( method_doc) {
890
- 'r' | 'p' => {
896
+ Some ( 'r' ) | Some ( 'p' ) => {
891
897
let generics = doc_generics ( method_doc, tcx, cdata, tag_method_ty_generics) ;
892
898
let predicates = doc_predicates ( method_doc, tcx, cdata, tag_method_ty_generics) ;
893
899
let fty = doc_method_fty ( method_doc, tcx, cdata) ;
@@ -904,7 +910,7 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
904
910
container,
905
911
provided_source) ) )
906
912
}
907
- 't' => {
913
+ Some ( 't' ) => {
908
914
ty:: TypeTraitItem ( Rc :: new ( ty:: AssociatedType {
909
915
name : name,
910
916
vis : vis,
@@ -924,8 +930,10 @@ pub fn get_trait_item_def_ids(cdata: Cmd, id: ast::NodeId)
924
930
reader:: tagged_docs ( item, tag_item_trait_item, |mth| {
925
931
let def_id = item_def_id ( mth, cdata) ;
926
932
match item_sort ( mth) {
927
- 'r' | 'p' => result. push ( ty:: MethodTraitItemId ( def_id) ) ,
928
- 't' => result. push ( ty:: TypeTraitItemId ( def_id) ) ,
933
+ Some ( 'r' ) | Some ( 'p' ) => {
934
+ result. push ( ty:: MethodTraitItemId ( def_id) ) ;
935
+ }
936
+ Some ( 't' ) => result. push ( ty:: TypeTraitItemId ( def_id) ) ,
929
937
_ => panic ! ( "unknown trait item sort" ) ,
930
938
}
931
939
true
@@ -954,7 +962,7 @@ pub fn get_provided_trait_methods<'tcx>(intr: Rc<IdentInterner>,
954
962
let did = item_def_id ( mth_id, cdata) ;
955
963
let mth = lookup_item ( did. node , data) ;
956
964
957
- if item_sort ( mth) == 'p' {
965
+ if item_sort ( mth) == Some ( 'p' ) {
958
966
let trait_item = get_impl_or_trait_item ( intr. clone ( ) ,
959
967
cdata,
960
968
did. node ,
@@ -1558,7 +1566,7 @@ pub fn is_associated_type(cdata: Cmd, id: ast::NodeId) -> bool {
1558
1566
let items = reader:: get_doc ( rbml:: Doc :: new ( cdata. data ( ) ) , tag_items) ;
1559
1567
match maybe_find_item ( id, items) {
1560
1568
None => false ,
1561
- Some ( item) => item_sort ( item) == 't' ,
1569
+ Some ( item) => item_sort ( item) == Some ( 't' ) ,
1562
1570
}
1563
1571
}
1564
1572
0 commit comments