Skip to content
Permalink
Browse files

syntax: refactor with new `fn parse_use_tree_glob_or_nested`.

  • Loading branch information...
Centril committed Oct 7, 2019
1 parent 9c6582a commit 6b23c22ccad4044476b65fc8f3e32794f1884781
Showing with 11 additions and 10 deletions.
  1. +11 −10 src/libsyntax/parse/parser/item.rs
@@ -1077,21 +1077,13 @@ impl<'a> Parser<'a> {
);
}

if self.eat(&token::BinOp(token::Star)) {
UseTreeKind::Glob
} else {
UseTreeKind::Nested(self.parse_use_tree_list()?)
}
self.parse_use_tree_glob_or_nested()?
} else {
// `use path::*;` or `use path::{...};` or `use path;` or `use path as bar;`
prefix = self.parse_path(PathStyle::Mod)?;

if self.eat(&token::ModSep) {
if self.eat(&token::BinOp(token::Star)) {
UseTreeKind::Glob
} else {
UseTreeKind::Nested(self.parse_use_tree_list()?)
}
self.parse_use_tree_glob_or_nested()?
} else {
UseTreeKind::Simple(self.parse_rename()?, DUMMY_NODE_ID, DUMMY_NODE_ID)
}
@@ -1100,6 +1092,15 @@ impl<'a> Parser<'a> {
Ok(UseTree { prefix, kind, span: lo.to(self.prev_span) })
}

/// Parses `*` or `{...}`.
fn parse_use_tree_glob_or_nested(&mut self) -> PResult<'a, UseTreeKind> {
Ok(if self.eat(&token::BinOp(token::Star)) {
UseTreeKind::Glob
} else {
UseTreeKind::Nested(self.parse_use_tree_list()?)
})
}

/// Parses a `UseTreeKind::Nested(list)`.
///
/// ```

0 comments on commit 6b23c22

Please sign in to comment.
You can’t perform that action at this time.