1
1
use rustc_middle:: mir:: interpret:: { ConstValue , Scalar } ;
2
2
use rustc_middle:: mir:: tcx:: PlaceTy ;
3
+ use rustc_middle:: ty:: cast:: mir_cast_kind;
3
4
use rustc_middle:: { mir:: * , thir:: * , ty} ;
4
5
use rustc_span:: Span ;
5
6
use rustc_target:: abi:: VariantIdx ;
@@ -142,7 +143,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
142
143
}
143
144
144
145
fn parse_rvalue ( & self , expr_id : ExprId ) -> PResult < Rvalue < ' tcx > > {
145
- parse_by_kind ! ( self , expr_id, _ , "rvalue" ,
146
+ parse_by_kind ! ( self , expr_id, expr , "rvalue" ,
146
147
@call( "mir_discriminant" , args) => self . parse_place( args[ 0 ] ) . map( Rvalue :: Discriminant ) ,
147
148
@call( "mir_checked" , args) => {
148
149
parse_by_kind!( self , args[ 0 ] , _, "binary op" ,
@@ -167,6 +168,12 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
167
168
ExprKind :: Repeat { value, count } => Ok (
168
169
Rvalue :: Repeat ( self . parse_operand( * value) ?, * count)
169
170
) ,
171
+ ExprKind :: Cast { source } => {
172
+ let source = self . parse_operand( * source) ?;
173
+ let source_ty = source. ty( self . body. local_decls( ) , self . tcx) ;
174
+ let cast_kind = mir_cast_kind( source_ty, expr. ty) ;
175
+ Ok ( Rvalue :: Cast ( cast_kind, source, expr. ty) )
176
+ } ,
170
177
_ => self . parse_operand( expr_id) . map( Rvalue :: Use ) ,
171
178
)
172
179
}
0 commit comments