diff options
| author | bors <bors@rust-lang.org> | 2018-11-22 10:04:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-11-22 10:04:41 +0000 |
| commit | 93fa2d76bd9a8ffbbb46df2da6d27c13ee7fa73e (patch) | |
| tree | 35b359452ea12e799c831d01c01262ec7fc1d4ec /src/libsyntax/parse/parser.rs | |
| parent | f3adec65dd0b05a0a30cd2c134f252e8bece0b76 (diff) | |
| parent | 61d7b3e9b028ba1a682448e8bdc6212552ce1ff3 (diff) | |
| download | rust-93fa2d76bd9a8ffbbb46df2da6d27c13ee7fa73e.tar.gz rust-93fa2d76bd9a8ffbbb46df2da6d27c13ee7fa73e.zip | |
Auto merge of #56155 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #55367 (lint if a private item has doctests) - #55485 (Return &T / &mut T in ManuallyDrop Deref(Mut) impl) - #55784 (Clarifying documentation for collections::hash_map::Entry::or_insert) - #55961 (Fix VecDeque pretty-printer) - #55980 (Suggest on closure args count mismatching with pipe span) - #56002 (fix #55972: Erroneous self arguments on bare functions emit subpar compilation error) - #56063 (Update any.rs documentation using keyword dyn) - #56067 (Add SGX target to rustc) - #56078 (Fix error message for `-C panic=xxx`.) - #56106 (Remove some incorrect doc comments) - #56126 (core/benches/num: Add `from_str/from_str_radix()` benchmarks) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b4fc9c2c6fc..e2f09affd4f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1824,6 +1824,14 @@ impl<'a> Parser<'a> { fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> { maybe_whole!(self, NtArg, |x| x); + if let Ok(Some(_)) = self.parse_self_arg() { + let mut err = self.struct_span_err(self.prev_span, + "unexpected `self` argument in function"); + err.span_label(self.prev_span, + "`self` is only valid as the first argument of an associated function"); + return Err(err); + } + let (pat, ty) = if require_name || self.is_named_argument() { debug!("parse_arg_general parse_pat (require_name:{})", require_name); @@ -5385,11 +5393,12 @@ impl<'a> Parser<'a> { fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool) -> PResult<'a, (Vec<Arg> , bool)> { + self.expect(&token::OpenDelim(token::Paren))?; + let sp = self.span; let mut variadic = false; let args: Vec<Option<Arg>> = - self.parse_unspanned_seq( - &token::OpenDelim(token::Paren), + self.parse_seq_to_before_end( &token::CloseDelim(token::Paren), SeqSep::trailing_allowed(token::Comma), |p| { @@ -5436,6 +5445,8 @@ impl<'a> Parser<'a> { } )?; + self.eat(&token::CloseDelim(token::Paren)); + let args: Vec<_> = args.into_iter().filter_map(|x| x).collect(); if variadic && args.is_empty() { |
