about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser/path.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-17 13:46:11 +0200
committerGitHub <noreply@github.com>2019-10-17 13:46:11 +0200
commitaccc6e7e4aea2ca6482d27766e89549a4890e07a (patch)
treeda3ce96edd11e1adbf73aed3648260a25a5c0975 /src/libsyntax/parse/parser/path.rs
parent55f2ac2483531977f4b1b9f79753b0f9c82bbc16 (diff)
parent8ca16ddfd4d92b4aca970478eeffa4d1e5fe30be (diff)
downloadrust-accc6e7e4aea2ca6482d27766e89549a4890e07a.tar.gz
rust-accc6e7e4aea2ca6482d27766e89549a4890e07a.zip
Rollup merge of #65465 - Centril:split-syntax-1, r=petrochenkov
Move syntax::ext to a syntax_expand and refactor some attribute logic

Part of https://github.com/rust-lang/rust/pull/65324.

r? @petrochenkov
Diffstat (limited to 'src/libsyntax/parse/parser/path.rs')
-rw-r--r--src/libsyntax/parse/parser/path.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs
index ca823991a2e..639d61a2b5c 100644
--- a/src/libsyntax/parse/parser/path.rs
+++ b/src/libsyntax/parse/parser/path.rs
@@ -111,7 +111,7 @@ impl<'a> Parser<'a> {
     /// Like `parse_path`, but also supports parsing `Word` meta items into paths for
     /// backwards-compatibility. This is used when parsing derive macro paths in `#[derive]`
     /// attributes.
-    pub fn parse_path_allowing_meta(&mut self, style: PathStyle) -> PResult<'a, Path> {
+    fn parse_path_allowing_meta(&mut self, style: PathStyle) -> PResult<'a, Path> {
         let meta_ident = match self.token.kind {
             token::Interpolated(ref nt) => match **nt {
                 token::NtMeta(ref item) => match item.tokens.is_empty() {
@@ -129,7 +129,22 @@ impl<'a> Parser<'a> {
         self.parse_path(style)
     }
 
-    crate fn parse_path_segments(
+    /// Parse a list of paths inside `#[derive(path_0, ..., path_n)]`.
+    crate fn parse_derive_paths(&mut self) -> PResult<'a, Vec<Path>> {
+        self.expect(&token::OpenDelim(token::Paren))?;
+        let mut list = Vec::new();
+        while !self.eat(&token::CloseDelim(token::Paren)) {
+            let path = self.parse_path_allowing_meta(PathStyle::Mod)?;
+            list.push(path);
+            if !self.eat(&token::Comma) {
+                self.expect(&token::CloseDelim(token::Paren))?;
+                break
+            }
+        }
+        Ok(list)
+    }
+
+    pub(super) fn parse_path_segments(
         &mut self,
         segments: &mut Vec<PathSegment>,
         style: PathStyle,