@@ -42,6 +42,29 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
42
42
@call( "mir_goto" , args) => {
43
43
Ok ( TerminatorKind :: Goto { target: self . parse_block( args[ 0 ] ) ? } )
44
44
} ,
45
+ @call( "mir_unreachable" , _args) => {
46
+ Ok ( TerminatorKind :: Unreachable )
47
+ } ,
48
+ @call( "mir_drop" , args) => {
49
+ Ok ( TerminatorKind :: Drop {
50
+ place: self . parse_place( args[ 0 ] ) ?,
51
+ target: self . parse_block( args[ 1 ] ) ?,
52
+ unwind: None ,
53
+ } )
54
+ } ,
55
+ @call( "mir_drop_and_replace" , args) => {
56
+ Ok ( TerminatorKind :: DropAndReplace {
57
+ place: self . parse_place( args[ 0 ] ) ?,
58
+ value: self . parse_operand( args[ 1 ] ) ?,
59
+ target: self . parse_block( args[ 2 ] ) ?,
60
+ unwind: None ,
61
+ } )
62
+ } ,
63
+ @call( "mir_call" , args) => {
64
+ let destination = self . parse_place( args[ 0 ] ) ?;
65
+ let target = self . parse_block( args[ 1 ] ) ?;
66
+ self . parse_call( args[ 2 ] , destination, target)
67
+ } ,
45
68
ExprKind :: Match { scrutinee, arms } => {
46
69
let discr = self . parse_operand( * scrutinee) ?;
47
70
self . parse_match( arms, expr. span) . map( |t| TerminatorKind :: SwitchInt { discr, targets: t } )
@@ -86,6 +109,32 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
86
109
Ok ( SwitchTargets :: new ( values. into_iter ( ) . zip ( targets) , otherwise) )
87
110
}
88
111
112
+ fn parse_call (
113
+ & self ,
114
+ expr_id : ExprId ,
115
+ destination : Place < ' tcx > ,
116
+ target : BasicBlock ,
117
+ ) -> PResult < TerminatorKind < ' tcx > > {
118
+ parse_by_kind ! ( self , expr_id, _, "function call" ,
119
+ ExprKind :: Call { fun, args, from_hir_call, fn_span, .. } => {
120
+ let fun = self . parse_operand( * fun) ?;
121
+ let args = args
122
+ . iter( )
123
+ . map( |arg| self . parse_operand( * arg) )
124
+ . collect:: <PResult <Vec <_>>>( ) ?;
125
+ Ok ( TerminatorKind :: Call {
126
+ func: fun,
127
+ args,
128
+ destination,
129
+ target: Some ( target) ,
130
+ cleanup: None ,
131
+ from_hir_call: * from_hir_call,
132
+ fn_span: * fn_span,
133
+ } )
134
+ } ,
135
+ )
136
+ }
137
+
89
138
fn parse_rvalue ( & self , expr_id : ExprId ) -> PResult < Rvalue < ' tcx > > {
90
139
parse_by_kind ! ( self , expr_id, _, "rvalue" ,
91
140
@call( "mir_discriminant" , args) => self . parse_place( args[ 0 ] ) . map( Rvalue :: Discriminant ) ,
0 commit comments