diff options
| author | bors <bors@rust-lang.org> | 2017-04-06 06:07:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-04-06 06:07:42 +0000 |
| commit | e5e92753cc3e12c3c468b6badaf340fe4443145c (patch) | |
| tree | ad85ffcb0203d3ff2468ce31afb4ef0cd03759f2 /src/libsyntax/parse | |
| parent | 1a9b382168cbf405589fbba7215ace700c067879 (diff) | |
| parent | 89b364d687b7a3d16fb9553f7b5b0c034c406d91 (diff) | |
| download | rust-e5e92753cc3e12c3c468b6badaf340fe4443145c.tar.gz rust-e5e92753cc3e12c3c468b6badaf340fe4443145c.zip | |
Auto merge of #41102 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests - Successful merges: #40908, #41011, #41026, #41037, #41050 - Failed merges:
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8595bfc9f79..0dd2c03acb6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1767,6 +1767,26 @@ impl<'a> Parser<'a> { }) } + /// Like `parse_path`, but also supports parsing `Word` meta items into paths for back-compat. + /// This is used when parsing derive macro paths in `#[derive]` attributes. + pub fn parse_path_allowing_meta(&mut self, mode: PathStyle) -> PResult<'a, ast::Path> { + let meta_ident = match self.token { + token::Interpolated(ref nt) => match **nt { + token::NtMeta(ref meta) => match meta.node { + ast::MetaItemKind::Word => Some(ast::Ident::with_empty_ctxt(meta.name)), + _ => None, + }, + _ => None, + }, + _ => None, + }; + if let Some(ident) = meta_ident { + self.bump(); + return Ok(ast::Path::from_ident(self.prev_span, ident)); + } + self.parse_path(mode) + } + /// Examples: /// - `a::b<T,U>::c<V,W>` /// - `a::b<T,U>::c(V) -> W` |
