@@ -21,7 +21,7 @@ use std::iter;
2121/// A `LitKind`-like enum to fold constant `Expr`s into.
2222#[ derive( Debug , Clone ) ]
2323pub enum Constant < ' tcx > {
24- Adt ( rustc_middle:: mir:: ConstantKind < ' tcx > ) ,
24+ Adt ( rustc_middle:: mir:: Const < ' tcx > ) ,
2525 /// A `String` (e.g., "abc").
2626 Str ( String ) ,
2727 /// A binary string (e.g., `b"abc"`).
@@ -482,7 +482,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
482482 . tcx
483483 . const_eval_resolve ( self . param_env , mir:: UnevaluatedConst :: new ( def_id, args) , None )
484484 . ok ( )
485- . map ( |val| rustc_middle:: mir:: ConstantKind :: from_value ( val, ty) ) ?;
485+ . map ( |val| rustc_middle:: mir:: Const :: from_value ( val, ty) ) ?;
486486 let result = miri_to_const ( self . lcx , result) ?;
487487 self . source = ConstantSource :: Constant ;
488488 Some ( result)
@@ -655,10 +655,10 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
655655 }
656656}
657657
658- pub fn miri_to_const < ' tcx > ( lcx : & LateContext < ' tcx > , result : mir:: ConstantKind < ' tcx > ) -> Option < Constant < ' tcx > > {
658+ pub fn miri_to_const < ' tcx > ( lcx : & LateContext < ' tcx > , result : mir:: Const < ' tcx > ) -> Option < Constant < ' tcx > > {
659659 use rustc_middle:: mir:: ConstValue ;
660660 match result {
661- mir:: ConstantKind :: Val ( ConstValue :: Scalar ( Scalar :: Int ( int) ) , _) => match result. ty ( ) . kind ( ) {
661+ mir:: Const :: Val ( ConstValue :: Scalar ( Scalar :: Int ( int) ) , _) => match result. ty ( ) . kind ( ) {
662662 ty:: Adt ( adt_def, _) if adt_def. is_struct ( ) => Some ( Constant :: Adt ( result) ) ,
663663 ty:: Bool => Some ( Constant :: Bool ( int == ScalarInt :: TRUE ) ) ,
664664 ty:: Uint ( _) | ty:: Int ( _) => Some ( Constant :: Int ( int. assert_bits ( int. size ( ) ) ) ) ,
@@ -671,11 +671,11 @@ pub fn miri_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::ConstantKind<'t
671671 ty:: RawPtr ( _) => Some ( Constant :: RawPtr ( int. assert_bits ( int. size ( ) ) ) ) ,
672672 _ => None ,
673673 } ,
674- mir:: ConstantKind :: Val ( cv, _) if matches ! ( result. ty( ) . kind( ) , ty:: Ref ( _, inner_ty, _) if matches!( inner_ty. kind( ) , ty:: Str ) ) => {
674+ mir:: Const :: Val ( cv, _) if matches ! ( result. ty( ) . kind( ) , ty:: Ref ( _, inner_ty, _) if matches!( inner_ty. kind( ) , ty:: Str ) ) => {
675675 let data = cv. try_get_slice_bytes_for_diagnostics ( lcx. tcx ) ?;
676676 String :: from_utf8 ( data. to_owned ( ) ) . ok ( ) . map ( Constant :: Str )
677677 }
678- mir:: ConstantKind :: Val ( ConstValue :: Indirect { alloc_id, offset : _ } , _) => {
678+ mir:: Const :: Val ( ConstValue :: Indirect { alloc_id, offset : _ } , _) => {
679679 let alloc = lcx. tcx . global_alloc ( alloc_id) . unwrap_memory ( ) ;
680680 match result. ty ( ) . kind ( ) {
681681 ty:: Adt ( adt_def, _) if adt_def. is_struct ( ) => Some ( Constant :: Adt ( result) ) ,
@@ -714,17 +714,17 @@ pub fn miri_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::ConstantKind<'t
714714fn field_of_struct < ' tcx > (
715715 adt_def : ty:: AdtDef < ' tcx > ,
716716 lcx : & LateContext < ' tcx > ,
717- result : mir:: ConstantKind < ' tcx > ,
717+ result : mir:: Const < ' tcx > ,
718718 field : & Ident ,
719- ) -> Option < mir:: ConstantKind < ' tcx > > {
720- if let mir:: ConstantKind :: Val ( result, ty) = result
719+ ) -> Option < mir:: Const < ' tcx > > {
720+ if let mir:: Const :: Val ( result, ty) = result
721721 && let Some ( dc) = lcx. tcx . try_destructure_mir_constant_for_diagnostics ( ( result, ty) )
722722 && let Some ( dc_variant) = dc. variant
723723 && let Some ( variant) = adt_def. variants ( ) . get ( dc_variant)
724724 && let Some ( field_idx) = variant. fields . iter ( ) . position ( |el| el. name == field. name )
725725 && let Some ( & ( val, ty) ) = dc. fields . get ( field_idx)
726726 {
727- Some ( mir:: ConstantKind :: Val ( val, ty) )
727+ Some ( mir:: Const :: Val ( val, ty) )
728728 }
729729 else {
730730 None
0 commit comments