diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-08 21:16:16 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-08 21:16:16 +0200 |
| commit | 551e3af9d09a03aaa246cac46b98124bc10835ba (patch) | |
| tree | b075a93df7cb608eae9650e497fb6a1336d80212 /src/parse/mod.rs | |
| parent | 5c327e249e03ac303e7fef40e2df6c6ef834db66 (diff) | |
Replace using with from
Diffstat (limited to 'src/parse/mod.rs')
| -rw-r--r-- | src/parse/mod.rs | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 1d893ad9..c3d532a7 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -728,33 +728,29 @@ fn import_expr(p: &mut Parser) -> Option<Expr> { let start = p.next_start(); p.assert(Token::Import); - let mut import_expr = None; - if let Some(path) = expr(p) { - let imports = if p.expect(Token::Using) { - if p.eat_if(Token::Star) { - // This is the wildcard scenario. - Imports::Wildcard - } else { - // This is the list of identifier scenario. - p.start_group(Group::Expr, TokenMode::Code); - let items = collection(p).0; - if items.is_empty() { - p.expected_at("import items", p.prev_end()); - } - - let idents = idents(p, items); - p.end_group(); - Imports::Idents(idents) - } - } else { - Imports::Idents(vec![]) - }; + let imports = if p.eat_if(Token::Star) { + // This is the wildcard scenario. + Imports::Wildcard + } else { + // This is the list of identifiers scenario. + p.start_group(Group::Imports, TokenMode::Code); + let items = collection(p).0; + if items.is_empty() { + p.expected_at("import items", p.prev_end()); + } + p.end_group(); + Imports::Idents(idents(p, items)) + }; - import_expr = Some(Expr::Import(ImportExpr { - span: p.span(start), - imports, - path: Box::new(path), - })); + let mut import_expr = None; + if p.expect(Token::From) { + if let Some(path) = expr(p) { + import_expr = Some(Expr::Import(ImportExpr { + span: p.span(start), + imports, + path: Box::new(path), + })); + } } import_expr |
