@@ -70,22 +70,6 @@ struct ConstAnalysis<'a, 'tcx> {
7070 param_env : ty:: ParamEnv < ' tcx > ,
7171}
7272
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-
8973impl < ' tcx > ValueAnalysis < ' tcx > for ConstAnalysis < ' _ , ' tcx > {
9074 type Value = FlatSet < ScalarTy < ' tcx > > ;
9175
@@ -377,6 +361,20 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
377361 }
378362 }
379363
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+
380378 fn wrap_scalar ( & self , scalar : Scalar , ty : Ty < ' tcx > ) -> FlatSet < ScalarTy < ' tcx > > {
381379 FlatSet :: Elem ( ScalarTy ( scalar, ty) )
382380 }
0 commit comments