Gracefully handle mistyping -> as => in function return type

This commit is contained in:
mibac138
2020-10-14 22:27:48 +02:00
parent c4926d01ad
commit 5404deeb64
9 changed files with 96 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
use super::ty::{AllowPlus, RecoverQPath};
use super::ty::{AllowPlus, RecoverFatArrow, RecoverQPath};
use super::{Parser, TokenType};
use crate::maybe_whole;
use rustc_ast::ptr::P;
@@ -231,7 +231,8 @@ impl<'a> Parser<'a> {
// `(T, U) -> R`
let (inputs, _) = self.parse_paren_comma_seq(|p| p.parse_ty())?;
let span = ident.span.to(self.prev_token.span);
let output = self.parse_ret_ty(AllowPlus::No, RecoverQPath::No)?;
let output =
self.parse_ret_ty(AllowPlus::No, RecoverQPath::No, RecoverFatArrow::No)?;
ParenthesizedArgs { inputs, output, span }.into()
};