eat CloseDelim

This commit is contained in:
Axary 2018-11-16 13:54:49 +01:00
parent 80c2101b20
commit 218e35efa1
2 changed files with 17 additions and 2 deletions

View File

@ -5385,11 +5385,16 @@ impl<'a> Parser<'a> {
fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool) fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
-> PResult<'a, (Vec<Arg> , bool)> { -> PResult<'a, (Vec<Arg> , bool)> {
self.expect(&token::OpenDelim(token::Paren))?;
if let Ok(Some(_)) = self.parse_self_arg() {
return Err(self.fatal("unexpected `self` argument in bare function"))
}
let sp = self.span; let sp = self.span;
let mut variadic = false; let mut variadic = false;
let args: Vec<Option<Arg>> = let args: Vec<Option<Arg>> =
self.parse_unspanned_seq( self.parse_seq_to_before_end(
&token::OpenDelim(token::Paren),
&token::CloseDelim(token::Paren), &token::CloseDelim(token::Paren),
SeqSep::trailing_allowed(token::Comma), SeqSep::trailing_allowed(token::Comma),
|p| { |p| {
@ -5436,6 +5441,8 @@ impl<'a> Parser<'a> {
} }
)?; )?;
self.eat(&token::CloseDelim(token::Paren));
let args: Vec<_> = args.into_iter().filter_map(|x| x).collect(); let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
if variadic && args.is_empty() { if variadic && args.is_empty() {

View File

@ -0,0 +1,8 @@
error: unexpected `self` argument in bare function
--> $DIR/bare-function-self.rs:12:11
|
LL | fn a(&self) { }
| ^
error: aborting due to previous error