@@ -269,12 +269,6 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
269
269
let data = VariantData {
270
270
ctor_kind : variant. ctor_kind ,
271
271
discr : variant. discr ,
272
- evaluated_discr : match variant. discr {
273
- ty:: VariantDiscr :: Explicit ( def_id) => {
274
- ty:: queries:: monomorphic_const_eval:: get ( tcx, DUMMY_SP , def_id) . ok ( )
275
- }
276
- ty:: VariantDiscr :: Relative ( _) => None
277
- } ,
278
272
struct_ctor : None ,
279
273
} ;
280
274
@@ -408,7 +402,6 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
408
402
let data = VariantData {
409
403
ctor_kind : variant. ctor_kind ,
410
404
discr : variant. discr ,
411
- evaluated_discr : None ,
412
405
struct_ctor : Some ( def_id. index ) ,
413
406
} ;
414
407
@@ -697,7 +690,6 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
697
690
EntryKind :: Struct ( self . lazy ( & VariantData {
698
691
ctor_kind : variant. ctor_kind ,
699
692
discr : variant. discr ,
700
- evaluated_discr : None ,
701
693
struct_ctor : struct_ctor,
702
694
} ) , repr_options)
703
695
}
@@ -708,7 +700,6 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
708
700
EntryKind :: Union ( self . lazy ( & VariantData {
709
701
ctor_kind : variant. ctor_kind ,
710
702
discr : variant. discr ,
711
- evaluated_discr : None ,
712
703
struct_ctor : None ,
713
704
} ) , repr_options)
714
705
}
@@ -1037,6 +1028,17 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
1037
1028
EntryBuilder :: encode_info_for_foreign_item,
1038
1029
( def_id, ni) ) ;
1039
1030
}
1031
+ fn visit_variant ( & mut self ,
1032
+ v : & ' tcx hir:: Variant ,
1033
+ g : & ' tcx hir:: Generics ,
1034
+ id : ast:: NodeId ) {
1035
+ intravisit:: walk_variant ( self , v, g, id) ;
1036
+
1037
+ if let Some ( discr) = v. node . disr_expr {
1038
+ let def_id = self . index . tcx . hir . body_owner_def_id ( discr) ;
1039
+ self . index . record ( def_id, EntryBuilder :: encode_info_for_embedded_const, def_id) ;
1040
+ }
1041
+ }
1040
1042
fn visit_generics ( & mut self , generics : & ' tcx hir:: Generics ) {
1041
1043
intravisit:: walk_generics ( self , generics) ;
1042
1044
self . index . encode_info_for_generics ( generics) ;
@@ -1160,6 +1162,32 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
1160
1162
}
1161
1163
}
1162
1164
1165
+ fn encode_info_for_embedded_const ( & mut self , def_id : DefId ) -> Entry < ' tcx > {
1166
+ debug ! ( "EntryBuilder::encode_info_for_embedded_const({:?})" , def_id) ;
1167
+ let tcx = self . tcx ;
1168
+ let id = tcx. hir . as_local_node_id ( def_id) . unwrap ( ) ;
1169
+ let body = tcx. hir . body_owned_by ( id) ;
1170
+
1171
+ Entry {
1172
+ kind : EntryKind :: Const ( ty:: queries:: mir_const_qualif:: get ( tcx, DUMMY_SP , def_id) ) ,
1173
+ visibility : self . lazy ( & ty:: Visibility :: Public ) ,
1174
+ span : self . lazy ( & tcx. def_span ( def_id) ) ,
1175
+ attributes : LazySeq :: empty ( ) ,
1176
+ children : LazySeq :: empty ( ) ,
1177
+ stability : None ,
1178
+ deprecation : None ,
1179
+
1180
+ ty : Some ( self . encode_item_type ( def_id) ) ,
1181
+ inherent_impls : LazySeq :: empty ( ) ,
1182
+ variances : LazySeq :: empty ( ) ,
1183
+ generics : Some ( self . encode_generics ( def_id) ) ,
1184
+ predicates : Some ( self . encode_predicates ( def_id) ) ,
1185
+
1186
+ ast : Some ( self . encode_body ( body) ) ,
1187
+ mir : self . encode_mir ( def_id) ,
1188
+ }
1189
+ }
1190
+
1163
1191
fn encode_attributes ( & mut self , attrs : & [ ast:: Attribute ] ) -> LazySeq < ast:: Attribute > {
1164
1192
// NOTE: This must use lazy_seq_from_slice(), not lazy_seq() because
1165
1193
// we really on the HashStable specialization for [Attribute]
0 commit comments