@@ -21,7 +21,7 @@ use std::iter;
21
21
/// A `LitKind`-like enum to fold constant `Expr`s into.
22
22
#[ derive( Debug , Clone ) ]
23
23
pub enum Constant < ' tcx > {
24
- Adt ( rustc_middle:: mir:: ConstantKind < ' tcx > ) ,
24
+ Adt ( rustc_middle:: mir:: Const < ' tcx > ) ,
25
25
/// A `String` (e.g., "abc").
26
26
Str ( String ) ,
27
27
/// A binary string (e.g., `b"abc"`).
@@ -482,7 +482,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
482
482
. tcx
483
483
. const_eval_resolve ( self . param_env , mir:: UnevaluatedConst :: new ( def_id, args) , None )
484
484
. ok ( )
485
- . map ( |val| rustc_middle:: mir:: ConstantKind :: from_value ( val, ty) ) ?;
485
+ . map ( |val| rustc_middle:: mir:: Const :: from_value ( val, ty) ) ?;
486
486
let result = miri_to_const ( self . lcx , result) ?;
487
487
self . source = ConstantSource :: Constant ;
488
488
Some ( result)
@@ -655,10 +655,10 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
655
655
}
656
656
}
657
657
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 > > {
659
659
use rustc_middle:: mir:: ConstValue ;
660
660
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 ( ) {
662
662
ty:: Adt ( adt_def, _) if adt_def. is_struct ( ) => Some ( Constant :: Adt ( result) ) ,
663
663
ty:: Bool => Some ( Constant :: Bool ( int == ScalarInt :: TRUE ) ) ,
664
664
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
671
671
ty:: RawPtr ( _) => Some ( Constant :: RawPtr ( int. assert_bits ( int. size ( ) ) ) ) ,
672
672
_ => None ,
673
673
} ,
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 ) ) => {
675
675
let data = cv. try_get_slice_bytes_for_diagnostics ( lcx. tcx ) ?;
676
676
String :: from_utf8 ( data. to_owned ( ) ) . ok ( ) . map ( Constant :: Str )
677
677
}
678
- mir:: ConstantKind :: Val ( ConstValue :: Indirect { alloc_id, offset : _ } , _) => {
678
+ mir:: Const :: Val ( ConstValue :: Indirect { alloc_id, offset : _ } , _) => {
679
679
let alloc = lcx. tcx . global_alloc ( alloc_id) . unwrap_memory ( ) ;
680
680
match result. ty ( ) . kind ( ) {
681
681
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
714
714
fn field_of_struct < ' tcx > (
715
715
adt_def : ty:: AdtDef < ' tcx > ,
716
716
lcx : & LateContext < ' tcx > ,
717
- result : mir:: ConstantKind < ' tcx > ,
717
+ result : mir:: Const < ' tcx > ,
718
718
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
721
721
&& let Some ( dc) = lcx. tcx . try_destructure_mir_constant_for_diagnostics ( ( result, ty) )
722
722
&& let Some ( dc_variant) = dc. variant
723
723
&& let Some ( variant) = adt_def. variants ( ) . get ( dc_variant)
724
724
&& let Some ( field_idx) = variant. fields . iter ( ) . position ( |el| el. name == field. name )
725
725
&& let Some ( & ( val, ty) ) = dc. fields . get ( field_idx)
726
726
{
727
- Some ( mir:: ConstantKind :: Val ( val, ty) )
727
+ Some ( mir:: Const :: Val ( val, ty) )
728
728
}
729
729
else {
730
730
None
0 commit comments