@@ -75,6 +75,9 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
7575 @call( mir_call, args) => {
7676 self . parse_call( args)
7777 } ,
78+ @call( mir_tail_call, args) => {
79+ self . parse_tail_call( args)
80+ } ,
7881 ExprKind :: Match { scrutinee, arms, .. } => {
7982 let discr = self . parse_operand( * scrutinee) ?;
8083 self . parse_match( arms, expr. span) . map( |t| TerminatorKind :: SwitchInt { discr, targets: t } )
@@ -187,6 +190,25 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
187190 )
188191 }
189192
193+ fn parse_tail_call ( & self , args : & [ ExprId ] ) -> PResult < TerminatorKind < ' tcx > > {
194+ parse_by_kind ! ( self , args[ 0 ] , _, "tail call" ,
195+ ExprKind :: Call { fun, args, fn_span, .. } => {
196+ let fun = self . parse_operand( * fun) ?;
197+ let args = args
198+ . iter( )
199+ . map( |arg|
200+ Ok ( Spanned { node: self . parse_operand( * arg) ?, span: self . thir. exprs[ * arg] . span } )
201+ )
202+ . collect:: <PResult <Box <[ _] >>>( ) ?;
203+ Ok ( TerminatorKind :: TailCall {
204+ func: fun,
205+ args,
206+ fn_span: * fn_span,
207+ } )
208+ } ,
209+ )
210+ }
211+
190212 fn parse_rvalue ( & self , expr_id : ExprId ) -> PResult < Rvalue < ' tcx > > {
191213 parse_by_kind ! ( self , expr_id, expr, "rvalue" ,
192214 @call( mir_discriminant, args) => self . parse_place( args[ 0 ] ) . map( Rvalue :: Discriminant ) ,
0 commit comments