@@ -418,6 +418,7 @@ impl<'tcx> EntryKind<'tcx> {
418
418
EntryKind :: Mod ( _) => Def :: Mod ( did) ,
419
419
EntryKind :: Variant ( _) => Def :: Variant ( did) ,
420
420
EntryKind :: Trait ( _) => Def :: Trait ( did) ,
421
+ EntryKind :: TraitAlias ( _) => Def :: TraitAlias ( did) ,
421
422
EntryKind :: Enum ( ..) => Def :: Enum ( did) ,
422
423
EntryKind :: MacroDef ( _) => Def :: Macro ( did, MacroKind :: Bang ) ,
423
424
EntryKind :: ForeignType => Def :: ForeignTy ( did) ,
@@ -520,17 +521,26 @@ impl<'a, 'tcx> CrateMetadata {
520
521
}
521
522
522
523
pub fn get_trait_def ( & self , item_id : DefIndex , sess : & Session ) -> ty:: TraitDef {
523
- let data = match self . entry ( item_id) . kind {
524
- EntryKind :: Trait ( data) => data. decode ( ( self , sess) ) ,
525
- _ => bug ! ( ) ,
526
- } ;
527
-
528
- ty:: TraitDef :: new ( self . local_def_id ( item_id) ,
529
- data. unsafety ,
530
- data. paren_sugar ,
531
- data. has_auto_impl ,
532
- data. is_marker ,
533
- self . def_path_table . def_path_hash ( item_id) )
524
+ match self . entry ( item_id) . kind {
525
+ EntryKind :: Trait ( data) => {
526
+ let data = data. decode ( ( self , sess) ) ;
527
+ ty:: TraitDef :: new ( self . local_def_id ( item_id) ,
528
+ data. unsafety ,
529
+ data. paren_sugar ,
530
+ data. has_auto_impl ,
531
+ data. is_marker ,
532
+ self . def_path_table . def_path_hash ( item_id) )
533
+ } ,
534
+ EntryKind :: TraitAlias ( _) => {
535
+ ty:: TraitDef :: new ( self . local_def_id ( item_id) ,
536
+ hir:: Unsafety :: Normal ,
537
+ false ,
538
+ false ,
539
+ false ,
540
+ self . def_path_table . def_path_hash ( item_id) )
541
+ } ,
542
+ _ => bug ! ( "def-index does not refer to trait or trait alias" ) ,
543
+ }
534
544
}
535
545
536
546
fn get_variant ( & self ,
@@ -544,7 +554,7 @@ impl<'a, 'tcx> CrateMetadata {
544
554
EntryKind :: Variant ( data) |
545
555
EntryKind :: Struct ( data, _) |
546
556
EntryKind :: Union ( data, _) => data. decode ( self ) ,
547
- _ => bug ! ( ) ,
557
+ _ => bug ! ( "def-index does not refer to ADT" ) ,
548
558
} ;
549
559
550
560
let def_id = self . local_def_id ( data. struct_ctor . unwrap_or ( index) ) ;
@@ -615,10 +625,13 @@ impl<'a, 'tcx> CrateMetadata {
615
625
item_id : DefIndex ,
616
626
tcx : TyCtxt < ' a , ' tcx , ' tcx > )
617
627
-> ty:: GenericPredicates < ' tcx > {
618
- match self . entry ( item_id) . kind {
619
- EntryKind :: Trait ( data) => data. decode ( self ) . super_predicates . decode ( ( self , tcx) ) ,
620
- _ => bug ! ( ) ,
621
- }
628
+ let super_predicates = match self . entry ( item_id) . kind {
629
+ EntryKind :: Trait ( data) => data. decode ( self ) . super_predicates ,
630
+ EntryKind :: TraitAlias ( data) => data. decode ( self ) . super_predicates ,
631
+ _ => bug ! ( "def-index does not refer to trait or trait alias" ) ,
632
+ } ;
633
+
634
+ super_predicates. decode ( ( self , tcx) )
622
635
}
623
636
624
637
pub fn get_generics ( & self ,
@@ -656,7 +669,7 @@ impl<'a, 'tcx> CrateMetadata {
656
669
fn get_impl_data ( & self , id : DefIndex ) -> ImplData < ' tcx > {
657
670
match self . entry ( id) . kind {
658
671
EntryKind :: Impl ( data) => data. decode ( self ) ,
659
- _ => bug ! ( ) ,
672
+ _ => bug ! ( "def-index does not refer to impl" ) ,
660
673
}
661
674
}
662
675
@@ -833,7 +846,7 @@ impl<'a, 'tcx> CrateMetadata {
833
846
match self . entry ( id) . kind {
834
847
EntryKind :: AssociatedConst ( _, data, _) |
835
848
EntryKind :: Const ( data, _) => data. ast_promotable ,
836
- _ => bug ! ( ) ,
849
+ _ => bug ! ( "def-index does not refer to const" ) ,
837
850
}
838
851
}
839
852
@@ -859,7 +872,7 @@ impl<'a, 'tcx> CrateMetadata {
859
872
EntryKind :: AssociatedConst ( AssociatedContainer :: ImplFinal , qualif, _) => {
860
873
qualif. mir
861
874
}
862
- _ => bug ! ( ) ,
875
+ _ => bug ! ( "def-index does not refer to const" ) ,
863
876
}
864
877
}
865
878
@@ -1014,7 +1027,8 @@ impl<'a, 'tcx> CrateMetadata {
1014
1027
}
1015
1028
def_key. parent . and_then ( |parent_index| {
1016
1029
match self . entry ( parent_index) . kind {
1017
- EntryKind :: Trait ( _) => Some ( self . local_def_id ( parent_index) ) ,
1030
+ EntryKind :: Trait ( _) |
1031
+ EntryKind :: TraitAlias ( _) => Some ( self . local_def_id ( parent_index) ) ,
1018
1032
_ => None ,
1019
1033
}
1020
1034
} )
@@ -1092,15 +1106,15 @@ impl<'a, 'tcx> CrateMetadata {
1092
1106
match self . entry ( id) . kind {
1093
1107
EntryKind :: Const ( _, data) |
1094
1108
EntryKind :: AssociatedConst ( _, _, data) => data. decode ( self ) . 0 ,
1095
- _ => bug ! ( ) ,
1109
+ _ => bug ! ( "def-index does not refer to const" ) ,
1096
1110
}
1097
1111
}
1098
1112
1099
1113
pub fn get_macro ( & self , id : DefIndex ) -> MacroDef {
1100
1114
let entry = self . entry ( id) ;
1101
1115
match entry. kind {
1102
1116
EntryKind :: MacroDef ( macro_def) => macro_def. decode ( self ) ,
1103
- _ => bug ! ( ) ,
1117
+ _ => bug ! ( "def-index does not refer to macro def" ) ,
1104
1118
}
1105
1119
}
1106
1120
@@ -1133,7 +1147,7 @@ impl<'a, 'tcx> CrateMetadata {
1133
1147
EntryKind :: Variant ( data) |
1134
1148
EntryKind :: Struct ( data, _) => data. decode ( self ) . ctor_sig . unwrap ( ) ,
1135
1149
EntryKind :: Closure ( data) => data. decode ( self ) . sig ,
1136
- _ => bug ! ( ) ,
1150
+ _ => bug ! ( "def-index does not refer to function" ) ,
1137
1151
} ;
1138
1152
sig. decode ( ( self , tcx) )
1139
1153
}
0 commit comments