diff options
| author | bors <bors@rust-lang.org> | 2019-10-17 18:53:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-10-17 18:53:10 +0000 |
| commit | fa0f7d0080d8e7e9eb20aa9cbf8013f96c81287f (patch) | |
| tree | 50e8894f986895d96ddf501e5c894ee920d1bcc7 /src/libsyntax/parse/parser/path.rs | |
| parent | b04338087eed5f26c72bdb0e426dc38e215e2dbb (diff) | |
| parent | 060aedd385d363924bd7f645073eb74bb2aa8a5e (diff) | |
| download | rust-fa0f7d0080d8e7e9eb20aa9cbf8013f96c81287f.tar.gz rust-fa0f7d0080d8e7e9eb20aa9cbf8013f96c81287f.zip | |
Auto merge of #65495 - Centril:rollup-tguwjt5, r=Centril
Rollup of 8 pull requests Successful merges: - #65237 (Move debug_map assertions after check for err) - #65316 (make File::try_clone produce non-inheritable handles on Windows) - #65319 (InterpCx: make memory field public) - #65461 (Don't recommend ONCE_INIT in std::sync::Once) - #65465 (Move syntax::ext to a syntax_expand and refactor some attribute logic) - #65475 (add example for type_name) - #65478 (fmt::Write is about string slices, not byte slices) - #65486 (doc: fix typo in OsStrExt and OsStringExt) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax/parse/parser/path.rs')
| -rw-r--r-- | src/libsyntax/parse/parser/path.rs | 19 |
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, |
