diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-02-29 18:54:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-29 18:54:07 +0100 |
| commit | ad200af5c4cb4296b7dfcfab68fd8f1573f149e4 (patch) | |
| tree | 66a80f91baf1e87c8f5251eb4ee5f0aa66802f16 | |
| parent | cf48ca6170066602095b33e0f740d40e0d1c0836 (diff) | |
| parent | 65a666c339a515ed39e61319d5101c8b98e77ba2 (diff) | |
| download | rust-ad200af5c4cb4296b7dfcfab68fd8f1573f149e4.tar.gz rust-ad200af5c4cb4296b7dfcfab68fd8f1573f149e4.zip | |
Rollup merge of #69587 - petrochenkov:reqname, r=Centril
rustc_parse: Tweak the function parameter name check The function doesn't need a full token, only its edition. Noticed while implementing https://github.com/rust-lang/rust/pull/69384. I'm still not sure whether normalized or unnormalized token is a better fit for the edition check here, so https://github.com/rust-lang/rust/pull/69384 and this PR just keep the status quo behavior. r? @Centril
| -rw-r--r-- | src/librustc_parse/parser/item.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index ef4246609da..d00d9fc72bf 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -6,6 +6,7 @@ use crate::maybe_whole; use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, PResult, StashKey}; +use rustc_span::edition::Edition; use rustc_span::source_map::{self, Span}; use rustc_span::symbol::{kw, sym, Symbol}; use syntax::ast::{self, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID}; @@ -636,7 +637,7 @@ impl<'a> Parser<'a> { } pub fn parse_trait_item(&mut self) -> PResult<'a, Option<Option<P<AssocItem>>>> { - self.parse_assoc_item(|t| t.span.rust_2018()) + self.parse_assoc_item(|edition| edition >= Edition::Edition2018) } /// Parses associated items. @@ -1380,7 +1381,7 @@ impl<'a> Parser<'a> { /// The parsing configuration used to parse a parameter list (see `parse_fn_params`). /// /// The function decides if, per-parameter `p`, `p` must have a pattern or just a type. -type ReqName = fn(&token::Token) -> bool; +type ReqName = fn(Edition) -> bool; /// Parsing of functions and methods. impl<'a> Parser<'a> { @@ -1536,7 +1537,7 @@ impl<'a> Parser<'a> { let is_name_required = match self.token.kind { token::DotDotDot => false, - _ => req_name(&self.normalized_token), + _ => req_name(self.normalized_token.span.edition()), }; let (pat, ty) = if is_name_required || self.is_named_param() { debug!("parse_param_general parse_pat (is_name_required:{})", is_name_required); |
