diff options
| author | David Wood <david@davidtw.co> | 2018-12-07 10:54:14 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-12-07 11:56:56 +0100 |
| commit | e4dc15a96905217dbdf857159f67bfd79d5e4d7c (patch) | |
| tree | 76907ac1703661e40a087f574afd351400548895 /src/libsyntax/parse | |
| parent | a2fb99bc17527798aeeef1d7ccc61811a9362131 (diff) | |
| download | rust-e4dc15a96905217dbdf857159f67bfd79d5e4d7c.tar.gz rust-e4dc15a96905217dbdf857159f67bfd79d5e4d7c.zip | |
Add context for RFC 1685 change in 2018 edition.
This commit adds a note providing context for the change to argument names being required in the 2018 edition for trait methods.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c7eaf4d1eee..af63314b154 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1404,7 +1404,7 @@ impl<'a> Parser<'a> { // definition... // We don't allow argument names to be left off in edition 2018. - p.parse_arg_general(p.span.rust_2018()) + p.parse_arg_general(p.span.rust_2018(), true) })?; generics.where_clause = self.parse_where_clause()?; @@ -1817,7 +1817,7 @@ impl<'a> Parser<'a> { /// This version of parse arg doesn't necessarily require /// identifier names. - fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> { + fn parse_arg_general(&mut self, require_name: bool, is_trait_item: bool) -> PResult<'a, Arg> { maybe_whole!(self, NtArg, |x| x); if let Ok(Some(_)) = self.parse_self_arg() { @@ -1849,6 +1849,8 @@ impl<'a> Parser<'a> { String::from("<identifier>: <type>"), Applicability::HasPlaceholders, ); + } else if require_name && is_trait_item { + err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)"); } return Err(err); @@ -1914,7 +1916,7 @@ impl<'a> Parser<'a> { /// Parse a single function argument crate fn parse_arg(&mut self) -> PResult<'a, Arg> { - self.parse_arg_general(true) + self.parse_arg_general(true, false) } /// Parse an argument in a lambda header e.g. |arg, arg| @@ -5469,7 +5471,7 @@ impl<'a> Parser<'a> { } } } else { - match p.parse_arg_general(named_args) { + match p.parse_arg_general(named_args, false) { Ok(arg) => Ok(Some(arg)), Err(mut e) => { e.emit(); |
