@@ -70,22 +70,6 @@ struct ConstAnalysis<'a, 'tcx> {
70
70
param_env : ty:: ParamEnv < ' tcx > ,
71
71
}
72
72
73
- impl < ' tcx > ConstAnalysis < ' _ , ' tcx > {
74
- fn eval_discriminant (
75
- & self ,
76
- enum_ty : Ty < ' tcx > ,
77
- variant_index : VariantIdx ,
78
- ) -> Option < ScalarTy < ' tcx > > {
79
- if !enum_ty. is_enum ( ) {
80
- return None ;
81
- }
82
- let discr = enum_ty. discriminant_for_variant ( self . tcx , variant_index) ?;
83
- let discr_layout = self . tcx . layout_of ( self . param_env . and ( discr. ty ) ) . ok ( ) ?;
84
- let discr_value = Scalar :: try_from_uint ( discr. val , discr_layout. size ) ?;
85
- Some ( ScalarTy ( discr_value, discr. ty ) )
86
- }
87
- }
88
-
89
73
impl < ' tcx > ValueAnalysis < ' tcx > for ConstAnalysis < ' _ , ' tcx > {
90
74
type Value = FlatSet < ScalarTy < ' tcx > > ;
91
75
@@ -377,6 +361,20 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
377
361
}
378
362
}
379
363
364
+ fn eval_discriminant (
365
+ & self ,
366
+ enum_ty : Ty < ' tcx > ,
367
+ variant_index : VariantIdx ,
368
+ ) -> Option < ScalarTy < ' tcx > > {
369
+ if !enum_ty. is_enum ( ) {
370
+ return None ;
371
+ }
372
+ let discr = enum_ty. discriminant_for_variant ( self . tcx , variant_index) ?;
373
+ let discr_layout = self . tcx . layout_of ( self . param_env . and ( discr. ty ) ) . ok ( ) ?;
374
+ let discr_value = Scalar :: try_from_uint ( discr. val , discr_layout. size ) ?;
375
+ Some ( ScalarTy ( discr_value, discr. ty ) )
376
+ }
377
+
380
378
fn wrap_scalar ( & self , scalar : Scalar , ty : Ty < ' tcx > ) -> FlatSet < ScalarTy < ' tcx > > {
381
379
FlatSet :: Elem ( ScalarTy ( scalar, ty) )
382
380
}
0 commit comments