@@ -510,16 +510,17 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
510510 mir:: Operand :: Constant ( ref constant) => {
511511 let ty = self . monomorphize ( & constant. ty ) ;
512512 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- }
517513 mir:: Literal :: Promoted { index } => {
518514 let mir = & self . mir . promoted [ index] ;
519515 MirConstContext :: new ( self . ccx , mir, self . substs , IndexVec :: new ( ) ) . trans ( )
520516 }
521517 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+ }
523524 }
524525 }
525526 }
@@ -960,16 +961,17 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
960961 debug ! ( "trans_constant({:?})" , constant) ;
961962 let ty = self . monomorphize ( & constant. ty ) ;
962963 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- }
967964 mir:: Literal :: Promoted { index } => {
968965 let mir = & self . mir . promoted [ index] ;
969966 MirConstContext :: new ( bcx. ccx , mir, self . param_substs , IndexVec :: new ( ) ) . trans ( )
970967 }
971968 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+ }
973975 }
974976 } ;
975977
0 commit comments