@@ -510,16 +510,17 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
510
510
mir:: Operand :: Constant ( ref constant) => {
511
511
let ty = self . monomorphize ( & constant. ty ) ;
512
512
match constant. literal . clone ( ) {
513
- mir:: Literal :: Item { def_id, substs } => {
514
- let substs = self . monomorphize ( & substs) ;
515
- MirConstContext :: trans_def ( self . ccx , def_id, substs, IndexVec :: new ( ) )
516
- }
517
513
mir:: Literal :: Promoted { index } => {
518
514
let mir = & self . mir . promoted [ index] ;
519
515
MirConstContext :: new ( self . ccx , mir, self . substs , IndexVec :: new ( ) ) . trans ( )
520
516
}
521
517
mir:: Literal :: Value { value } => {
522
- Ok ( Const :: from_constval ( self . ccx , & value. val , ty) )
518
+ if let ConstVal :: Unevaluated ( def_id, substs) = value. val {
519
+ let substs = self . monomorphize ( & substs) ;
520
+ MirConstContext :: trans_def ( self . ccx , def_id, substs, IndexVec :: new ( ) )
521
+ } else {
522
+ Ok ( Const :: from_constval ( self . ccx , & value. val , ty) )
523
+ }
523
524
}
524
525
}
525
526
}
@@ -960,16 +961,17 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
960
961
debug ! ( "trans_constant({:?})" , constant) ;
961
962
let ty = self . monomorphize ( & constant. ty ) ;
962
963
let result = match constant. literal . clone ( ) {
963
- mir:: Literal :: Item { def_id, substs } => {
964
- let substs = self . monomorphize ( & substs) ;
965
- MirConstContext :: trans_def ( bcx. ccx , def_id, substs, IndexVec :: new ( ) )
966
- }
967
964
mir:: Literal :: Promoted { index } => {
968
965
let mir = & self . mir . promoted [ index] ;
969
966
MirConstContext :: new ( bcx. ccx , mir, self . param_substs , IndexVec :: new ( ) ) . trans ( )
970
967
}
971
968
mir:: Literal :: Value { value } => {
972
- Ok ( Const :: from_constval ( bcx. ccx , & value. val , ty) )
969
+ if let ConstVal :: Unevaluated ( def_id, substs) = value. val {
970
+ let substs = self . monomorphize ( & substs) ;
971
+ MirConstContext :: trans_def ( bcx. ccx , def_id, substs, IndexVec :: new ( ) )
972
+ } else {
973
+ Ok ( Const :: from_constval ( bcx. ccx , & value. val , ty) )
974
+ }
973
975
}
974
976
} ;
975
977
0 commit comments