diff options
Diffstat (limited to 'crates/ra_parser/src/grammar/items')
-rw-r--r-- | crates/ra_parser/src/grammar/items/use_item.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index 7a1693a34..f28f522b8 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs | |||
@@ -13,9 +13,8 @@ pub(super) fn use_item(p: &mut Parser, m: Marker) { | |||
13 | /// so handles both `some::path::{inner::path}` and `inner::path` in | 13 | /// so handles both `some::path::{inner::path}` and `inner::path` in |
14 | /// `use some::path::{inner::path};` | 14 | /// `use some::path::{inner::path};` |
15 | fn use_tree(p: &mut Parser) { | 15 | fn use_tree(p: &mut Parser) { |
16 | let la = p.nth(1); | ||
17 | let m = p.start(); | 16 | let m = p.start(); |
18 | match (p.current(), la) { | 17 | match p.current() { |
19 | // Finish the use_tree for cases of e.g. | 18 | // Finish the use_tree for cases of e.g. |
20 | // `use some::path::{self, *};` or `use *;` | 19 | // `use some::path::{self, *};` or `use *;` |
21 | // This does not handle cases such as `use some::path::*` | 20 | // This does not handle cases such as `use some::path::*` |
@@ -28,15 +27,15 @@ fn use_tree(p: &mut Parser) { | |||
28 | // use ::*; | 27 | // use ::*; |
29 | // use some::path::{*}; | 28 | // use some::path::{*}; |
30 | // use some::path::{::*}; | 29 | // use some::path::{::*}; |
31 | (T![*], _) => p.bump_any(), | 30 | T![*] => p.bump(T![*]), |
32 | (T![::], T![*]) => { | 31 | T![:] if p.at(T![::]) && p.nth(2) == T![*] => { |
33 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 | 32 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 |
34 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) | 33 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) |
35 | // but still parses and errors later: ('crate root in paths can only be used in start position') | 34 | // but still parses and errors later: ('crate root in paths can only be used in start position') |
36 | // FIXME: Add this error (if not out of scope) | 35 | // FIXME: Add this error (if not out of scope) |
37 | // In Rust 2018, it is always invalid (see above) | 36 | // In Rust 2018, it is always invalid (see above) |
38 | p.bump_any(); | 37 | p.bump(T![::]); |
39 | p.bump_any(); | 38 | p.bump(T![*]); |
40 | } | 39 | } |
41 | // Open a use tree list | 40 | // Open a use tree list |
42 | // Handles cases such as `use {some::path};` or `{inner::path}` in | 41 | // Handles cases such as `use {some::path};` or `{inner::path}` in |
@@ -47,10 +46,11 @@ fn use_tree(p: &mut Parser) { | |||
47 | // use {path::from::root}; // Rust 2015 | 46 | // use {path::from::root}; // Rust 2015 |
48 | // use ::{some::arbritrary::path}; // Rust 2015 | 47 | // use ::{some::arbritrary::path}; // Rust 2015 |
49 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig | 48 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig |
50 | (T!['{'], _) | (T![::], T!['{']) => { | 49 | T!['{'] => { |
51 | if p.at(T![::]) { | 50 | use_tree_list(p); |
52 | p.bump_any(); | 51 | } |
53 | } | 52 | T![:] if p.at(T![::]) && p.nth(2) == T!['{'] => { |
53 | p.bump(T![::]); | ||
54 | use_tree_list(p); | 54 | use_tree_list(p); |
55 | } | 55 | } |
56 | // Parse a 'standard' path. | 56 | // Parse a 'standard' path. |
@@ -80,8 +80,8 @@ fn use_tree(p: &mut Parser) { | |||
80 | // use Trait as _; | 80 | // use Trait as _; |
81 | opt_alias(p); | 81 | opt_alias(p); |
82 | } | 82 | } |
83 | T![::] => { | 83 | T![:] if p.at(T![::]) => { |
84 | p.bump_any(); | 84 | p.bump(T![::]); |
85 | match p.current() { | 85 | match p.current() { |
86 | T![*] => { | 86 | T![*] => { |
87 | p.bump_any(); | 87 | p.bump_any(); |