diff options
Diffstat (limited to 'crates/ra_syntax')
11 files changed, 539 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/grammar/items/use_item.rs b/crates/ra_syntax/src/grammar/items/use_item.rs index 1ee4349fd..b3c78f351 100644 --- a/crates/ra_syntax/src/grammar/items/use_item.rs +++ b/crates/ra_syntax/src/grammar/items/use_item.rs | |||
@@ -7,25 +7,75 @@ pub(super) fn use_item(p: &mut Parser) { | |||
7 | p.expect(SEMI); | 7 | p.expect(SEMI); |
8 | } | 8 | } |
9 | 9 | ||
10 | /// Parse a use 'tree', such as `some::path` in `use some::path;` | ||
11 | /// Note that this is called both by `use_item` and `use_tree_list`, | ||
12 | /// so handles both `some::path::{inner::path}` and `inner::path` in | ||
13 | /// `use some::path::{inner::path};` | ||
10 | fn use_tree(p: &mut Parser) { | 14 | fn use_tree(p: &mut Parser) { |
11 | let la = p.nth(1); | 15 | let la = p.nth(1); |
12 | let m = p.start(); | 16 | let m = p.start(); |
13 | match (p.current(), la) { | 17 | match (p.current(), la) { |
18 | // Finish the use_tree for cases of e.g. | ||
19 | // `use some::path::{self, *};` or `use *;` | ||
20 | // This does not handle cases such as `use some::path::*` | ||
21 | // N.B. in Rust 2015 `use *;` imports all from crate root | ||
22 | // however in Rust 2018 `use *;` errors: ('cannot glob-import all possible crates') | ||
23 | // TODO: Add this error (if not out of scope) | ||
24 | |||
25 | // test use_star | ||
26 | // use *; | ||
27 | // use ::*; | ||
28 | // use some::path::{*}; | ||
29 | // use some::path::{::*}; | ||
14 | (STAR, _) => p.bump(), | 30 | (STAR, _) => p.bump(), |
15 | (COLONCOLON, STAR) => { | 31 | (COLONCOLON, STAR) => { |
32 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 | ||
33 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) | ||
34 | // but still parses and errors later: ('crate root in paths can only be used in start position') | ||
35 | // TODO: Add this error (if not out of scope) | ||
36 | // In Rust 2018, it is always invalid (see above) | ||
16 | p.bump(); | 37 | p.bump(); |
17 | p.bump(); | 38 | p.bump(); |
18 | } | 39 | } |
40 | // Open a use tree list | ||
41 | // Handles cases such as `use {some::path};` or `{inner::path}` in | ||
42 | // `use some::path::{{inner::path}, other::path}` | ||
43 | |||
44 | // test use_tree_list | ||
45 | // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) | ||
46 | // use {path::from::root}; // Rust 2015 | ||
47 | // use ::{some::arbritrary::path}; // Rust 2015 | ||
48 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig | ||
19 | (L_CURLY, _) | (COLONCOLON, L_CURLY) => { | 49 | (L_CURLY, _) | (COLONCOLON, L_CURLY) => { |
20 | if p.at(COLONCOLON) { | 50 | if p.at(COLONCOLON) { |
21 | p.bump(); | 51 | p.bump(); |
22 | } | 52 | } |
23 | use_tree_list(p); | 53 | use_tree_list(p); |
24 | } | 54 | } |
55 | // Parse a 'standard' path. | ||
56 | // Also handles aliases (e.g. `use something as something_else`) | ||
57 | |||
58 | // test use_path | ||
59 | // use ::crate_name; // Rust 2018 - All flavours | ||
60 | // use crate_name; // Rust 2018 - Anchored paths | ||
61 | // use item_in_scope_or_crate_name; // Rust 2018 - Uniform Paths | ||
62 | // | ||
63 | // use self::module::Item; | ||
64 | // use crate::Item; | ||
65 | // use self::some::Struct; | ||
66 | // use crate_name::some_item; | ||
25 | _ if paths::is_path_start(p) => { | 67 | _ if paths::is_path_start(p) => { |
26 | paths::use_path(p); | 68 | paths::use_path(p); |
27 | match p.current() { | 69 | match p.current() { |
28 | AS_KW => { | 70 | AS_KW => { |
71 | // test use_alias | ||
72 | // use some::path as some_name; | ||
73 | // use some::{ | ||
74 | // other::path as some_other_name, | ||
75 | // different::path as different_name, | ||
76 | // yet::another::path, | ||
77 | // running::out::of::synonyms::for::different::* | ||
78 | // }; | ||
29 | opt_alias(p); | 79 | opt_alias(p); |
30 | } | 80 | } |
31 | COLONCOLON => { | 81 | COLONCOLON => { |
@@ -34,6 +84,9 @@ fn use_tree(p: &mut Parser) { | |||
34 | STAR => { | 84 | STAR => { |
35 | p.bump(); | 85 | p.bump(); |
36 | } | 86 | } |
87 | // test use_tree_list_after_path | ||
88 | // use crate::{Item}; | ||
89 | // use self::{Item}; | ||
37 | L_CURLY => use_tree_list(p), | 90 | L_CURLY => use_tree_list(p), |
38 | _ => { | 91 | _ => { |
39 | // is this unreachable? | 92 | // is this unreachable? |
@@ -46,7 +99,7 @@ fn use_tree(p: &mut Parser) { | |||
46 | } | 99 | } |
47 | _ => { | 100 | _ => { |
48 | m.abandon(p); | 101 | m.abandon(p); |
49 | p.err_and_bump("expected one of `*`, `::`, `{`, `self`, `super`, `indent`"); | 102 | p.err_and_bump("expected one of `*`, `::`, `{`, `self`, `super` or an indentifier"); |
50 | return; | 103 | return; |
51 | } | 104 | } |
52 | } | 105 | } |
diff --git a/crates/ra_syntax/tests/data/parser/inline/0114_use_path.rs b/crates/ra_syntax/tests/data/parser/inline/0114_use_path.rs new file mode 100644 index 000000000..1e436a6bc --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0114_use_path.rs | |||
@@ -0,0 +1,8 @@ | |||
1 | use ::crate_name; // Rust 2018 - All flavours | ||
2 | use crate_name; // Rust 2018 - Anchored paths | ||
3 | use item_in_scope_or_crate_name; // Rust 2018 - Uniform Paths | ||
4 | |||
5 | use self::module::Item; | ||
6 | use crate::Item; | ||
7 | use self::some::Struct; | ||
8 | use crate_name::some_item; | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0114_use_path.txt b/crates/ra_syntax/tests/data/parser/inline/0114_use_path.txt new file mode 100644 index 000000000..4dc68c3b1 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0114_use_path.txt | |||
@@ -0,0 +1,105 @@ | |||
1 | SOURCE_FILE@[0; 247) | ||
2 | USE_ITEM@[0; 17) | ||
3 | USE_KW@[0; 3) | ||
4 | WHITESPACE@[3; 4) | ||
5 | USE_TREE@[4; 16) | ||
6 | PATH@[4; 16) | ||
7 | PATH_SEGMENT@[4; 16) | ||
8 | COLONCOLON@[4; 6) | ||
9 | NAME_REF@[6; 16) | ||
10 | IDENT@[6; 16) "crate_name" | ||
11 | SEMI@[16; 17) | ||
12 | WHITESPACE@[17; 18) | ||
13 | COMMENT@[18; 45) | ||
14 | WHITESPACE@[45; 46) | ||
15 | USE_ITEM@[46; 61) | ||
16 | USE_KW@[46; 49) | ||
17 | WHITESPACE@[49; 50) | ||
18 | USE_TREE@[50; 60) | ||
19 | PATH@[50; 60) | ||
20 | PATH_SEGMENT@[50; 60) | ||
21 | NAME_REF@[50; 60) | ||
22 | IDENT@[50; 60) "crate_name" | ||
23 | SEMI@[60; 61) | ||
24 | WHITESPACE@[61; 62) | ||
25 | COMMENT@[62; 91) | ||
26 | WHITESPACE@[91; 92) | ||
27 | USE_ITEM@[92; 124) | ||
28 | USE_KW@[92; 95) | ||
29 | WHITESPACE@[95; 96) | ||
30 | USE_TREE@[96; 123) | ||
31 | PATH@[96; 123) | ||
32 | PATH_SEGMENT@[96; 123) | ||
33 | NAME_REF@[96; 123) | ||
34 | IDENT@[96; 123) "item_in_scope_or_crate_name" | ||
35 | SEMI@[123; 124) | ||
36 | WHITESPACE@[124; 125) | ||
37 | COMMENT@[125; 153) | ||
38 | WHITESPACE@[153; 155) | ||
39 | USE_ITEM@[155; 178) | ||
40 | USE_KW@[155; 158) | ||
41 | WHITESPACE@[158; 159) | ||
42 | USE_TREE@[159; 177) | ||
43 | PATH@[159; 177) | ||
44 | PATH@[159; 171) | ||
45 | PATH@[159; 163) | ||
46 | PATH_SEGMENT@[159; 163) | ||
47 | SELF_KW@[159; 163) | ||
48 | COLONCOLON@[163; 165) | ||
49 | PATH_SEGMENT@[165; 171) | ||
50 | NAME_REF@[165; 171) | ||
51 | IDENT@[165; 171) "module" | ||
52 | COLONCOLON@[171; 173) | ||
53 | PATH_SEGMENT@[173; 177) | ||
54 | NAME_REF@[173; 177) | ||
55 | IDENT@[173; 177) "Item" | ||
56 | SEMI@[177; 178) | ||
57 | WHITESPACE@[178; 179) | ||
58 | USE_ITEM@[179; 195) | ||
59 | USE_KW@[179; 182) | ||
60 | WHITESPACE@[182; 183) | ||
61 | USE_TREE@[183; 194) | ||
62 | PATH@[183; 194) | ||
63 | PATH@[183; 188) | ||
64 | PATH_SEGMENT@[183; 188) | ||
65 | CRATE_KW@[183; 188) | ||
66 | COLONCOLON@[188; 190) | ||
67 | PATH_SEGMENT@[190; 194) | ||
68 | NAME_REF@[190; 194) | ||
69 | IDENT@[190; 194) "Item" | ||
70 | SEMI@[194; 195) | ||
71 | WHITESPACE@[195; 196) | ||
72 | USE_ITEM@[196; 219) | ||
73 | USE_KW@[196; 199) | ||
74 | WHITESPACE@[199; 200) | ||
75 | USE_TREE@[200; 218) | ||
76 | PATH@[200; 218) | ||
77 | PATH@[200; 210) | ||
78 | PATH@[200; 204) | ||
79 | PATH_SEGMENT@[200; 204) | ||
80 | SELF_KW@[200; 204) | ||
81 | COLONCOLON@[204; 206) | ||
82 | PATH_SEGMENT@[206; 210) | ||
83 | NAME_REF@[206; 210) | ||
84 | IDENT@[206; 210) "some" | ||
85 | COLONCOLON@[210; 212) | ||
86 | PATH_SEGMENT@[212; 218) | ||
87 | NAME_REF@[212; 218) | ||
88 | IDENT@[212; 218) "Struct" | ||
89 | SEMI@[218; 219) | ||
90 | WHITESPACE@[219; 220) | ||
91 | USE_ITEM@[220; 246) | ||
92 | USE_KW@[220; 223) | ||
93 | WHITESPACE@[223; 224) | ||
94 | USE_TREE@[224; 245) | ||
95 | PATH@[224; 245) | ||
96 | PATH@[224; 234) | ||
97 | PATH_SEGMENT@[224; 234) | ||
98 | NAME_REF@[224; 234) | ||
99 | IDENT@[224; 234) "crate_name" | ||
100 | COLONCOLON@[234; 236) | ||
101 | PATH_SEGMENT@[236; 245) | ||
102 | NAME_REF@[236; 245) | ||
103 | IDENT@[236; 245) "some_item" | ||
104 | SEMI@[245; 246) | ||
105 | WHITESPACE@[246; 247) | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0115_use_alias.rs b/crates/ra_syntax/tests/data/parser/inline/0115_use_alias.rs new file mode 100644 index 000000000..c7a141bbd --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0115_use_alias.rs | |||
@@ -0,0 +1,7 @@ | |||
1 | use some::path as some_name; | ||
2 | use some::{ | ||
3 | other::path as some_other_name, | ||
4 | different::path as different_name, | ||
5 | yet::another::path, | ||
6 | running::out::of::synonyms::for::different::* | ||
7 | }; | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0115_use_alias.txt b/crates/ra_syntax/tests/data/parser/inline/0115_use_alias.txt new file mode 100644 index 000000000..f7b599476 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0115_use_alias.txt | |||
@@ -0,0 +1,124 @@ | |||
1 | SOURCE_FILE@[0; 181) | ||
2 | USE_ITEM@[0; 28) | ||
3 | USE_KW@[0; 3) | ||
4 | WHITESPACE@[3; 4) | ||
5 | USE_TREE@[4; 27) | ||
6 | PATH@[4; 14) | ||
7 | PATH@[4; 8) | ||
8 | PATH_SEGMENT@[4; 8) | ||
9 | NAME_REF@[4; 8) | ||
10 | IDENT@[4; 8) "some" | ||
11 | COLONCOLON@[8; 10) | ||
12 | PATH_SEGMENT@[10; 14) | ||
13 | NAME_REF@[10; 14) | ||
14 | IDENT@[10; 14) "path" | ||
15 | WHITESPACE@[14; 15) | ||
16 | ALIAS@[15; 27) | ||
17 | AS_KW@[15; 17) | ||
18 | WHITESPACE@[17; 18) | ||
19 | NAME@[18; 27) | ||
20 | IDENT@[18; 27) "some_name" | ||
21 | SEMI@[27; 28) | ||
22 | WHITESPACE@[28; 29) | ||
23 | USE_ITEM@[29; 180) | ||
24 | USE_KW@[29; 32) | ||
25 | WHITESPACE@[32; 33) | ||
26 | USE_TREE@[33; 179) | ||
27 | PATH@[33; 37) | ||
28 | PATH_SEGMENT@[33; 37) | ||
29 | NAME_REF@[33; 37) | ||
30 | IDENT@[33; 37) "some" | ||
31 | COLONCOLON@[37; 39) | ||
32 | USE_TREE_LIST@[39; 179) | ||
33 | L_CURLY@[39; 40) | ||
34 | WHITESPACE@[40; 42) | ||
35 | USE_TREE@[42; 72) | ||
36 | PATH@[42; 53) | ||
37 | PATH@[42; 47) | ||
38 | PATH_SEGMENT@[42; 47) | ||
39 | NAME_REF@[42; 47) | ||
40 | IDENT@[42; 47) "other" | ||
41 | COLONCOLON@[47; 49) | ||
42 | PATH_SEGMENT@[49; 53) | ||
43 | NAME_REF@[49; 53) | ||
44 | IDENT@[49; 53) "path" | ||
45 | WHITESPACE@[53; 54) | ||
46 | ALIAS@[54; 72) | ||
47 | AS_KW@[54; 56) | ||
48 | WHITESPACE@[56; 57) | ||
49 | NAME@[57; 72) | ||
50 | IDENT@[57; 72) "some_other_name" | ||
51 | COMMA@[72; 73) | ||
52 | WHITESPACE@[73; 75) | ||
53 | USE_TREE@[75; 108) | ||
54 | PATH@[75; 90) | ||
55 | PATH@[75; 84) | ||
56 | PATH_SEGMENT@[75; 84) | ||
57 | NAME_REF@[75; 84) | ||
58 | IDENT@[75; 84) "different" | ||
59 | COLONCOLON@[84; 86) | ||
60 | PATH_SEGMENT@[86; 90) | ||
61 | NAME_REF@[86; 90) | ||
62 | IDENT@[86; 90) "path" | ||
63 | WHITESPACE@[90; 91) | ||
64 | ALIAS@[91; 108) | ||
65 | AS_KW@[91; 93) | ||
66 | WHITESPACE@[93; 94) | ||
67 | NAME@[94; 108) | ||
68 | IDENT@[94; 108) "different_name" | ||
69 | COMMA@[108; 109) | ||
70 | WHITESPACE@[109; 111) | ||
71 | USE_TREE@[111; 129) | ||
72 | PATH@[111; 129) | ||
73 | PATH@[111; 123) | ||
74 | PATH@[111; 114) | ||
75 | PATH_SEGMENT@[111; 114) | ||
76 | NAME_REF@[111; 114) | ||
77 | IDENT@[111; 114) "yet" | ||
78 | COLONCOLON@[114; 116) | ||
79 | PATH_SEGMENT@[116; 123) | ||
80 | NAME_REF@[116; 123) | ||
81 | IDENT@[116; 123) "another" | ||
82 | COLONCOLON@[123; 125) | ||
83 | PATH_SEGMENT@[125; 129) | ||
84 | NAME_REF@[125; 129) | ||
85 | IDENT@[125; 129) "path" | ||
86 | COMMA@[129; 130) | ||
87 | WHITESPACE@[130; 132) | ||
88 | USE_TREE@[132; 177) | ||
89 | PATH@[132; 174) | ||
90 | PATH@[132; 163) | ||
91 | PATH@[132; 158) | ||
92 | PATH@[132; 148) | ||
93 | PATH@[132; 144) | ||
94 | PATH@[132; 139) | ||
95 | PATH_SEGMENT@[132; 139) | ||
96 | NAME_REF@[132; 139) | ||
97 | IDENT@[132; 139) "running" | ||
98 | COLONCOLON@[139; 141) | ||
99 | PATH_SEGMENT@[141; 144) | ||
100 | NAME_REF@[141; 144) | ||
101 | IDENT@[141; 144) "out" | ||
102 | COLONCOLON@[144; 146) | ||
103 | PATH_SEGMENT@[146; 148) | ||
104 | NAME_REF@[146; 148) | ||
105 | IDENT@[146; 148) "of" | ||
106 | COLONCOLON@[148; 150) | ||
107 | PATH_SEGMENT@[150; 158) | ||
108 | NAME_REF@[150; 158) | ||
109 | IDENT@[150; 158) "synonyms" | ||
110 | COLONCOLON@[158; 160) | ||
111 | err: `expected identifier` | ||
112 | PATH_SEGMENT@[160; 163) | ||
113 | ERROR@[160; 163) | ||
114 | FOR_KW@[160; 163) | ||
115 | COLONCOLON@[163; 165) | ||
116 | PATH_SEGMENT@[165; 174) | ||
117 | NAME_REF@[165; 174) | ||
118 | IDENT@[165; 174) "different" | ||
119 | COLONCOLON@[174; 176) | ||
120 | STAR@[176; 177) | ||
121 | WHITESPACE@[177; 178) | ||
122 | R_CURLY@[178; 179) | ||
123 | SEMI@[179; 180) | ||
124 | WHITESPACE@[180; 181) | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0116_use_star.rs b/crates/ra_syntax/tests/data/parser/inline/0116_use_star.rs new file mode 100644 index 000000000..6f15769a8 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0116_use_star.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | use *; | ||
2 | use ::*; | ||
3 | use some::path::{*}; | ||
4 | use some::path::{::*}; | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0116_use_star.txt b/crates/ra_syntax/tests/data/parser/inline/0116_use_star.txt new file mode 100644 index 000000000..2db3cbf9e --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0116_use_star.txt | |||
@@ -0,0 +1,59 @@ | |||
1 | SOURCE_FILE@[0; 60) | ||
2 | USE_ITEM@[0; 6) | ||
3 | USE_KW@[0; 3) | ||
4 | WHITESPACE@[3; 4) | ||
5 | USE_TREE@[4; 5) | ||
6 | STAR@[4; 5) | ||
7 | SEMI@[5; 6) | ||
8 | WHITESPACE@[6; 7) | ||
9 | USE_ITEM@[7; 15) | ||
10 | USE_KW@[7; 10) | ||
11 | WHITESPACE@[10; 11) | ||
12 | USE_TREE@[11; 14) | ||
13 | COLONCOLON@[11; 13) | ||
14 | STAR@[13; 14) | ||
15 | SEMI@[14; 15) | ||
16 | WHITESPACE@[15; 16) | ||
17 | USE_ITEM@[16; 36) | ||
18 | USE_KW@[16; 19) | ||
19 | WHITESPACE@[19; 20) | ||
20 | USE_TREE@[20; 35) | ||
21 | PATH@[20; 30) | ||
22 | PATH@[20; 24) | ||
23 | PATH_SEGMENT@[20; 24) | ||
24 | NAME_REF@[20; 24) | ||
25 | IDENT@[20; 24) "some" | ||
26 | COLONCOLON@[24; 26) | ||
27 | PATH_SEGMENT@[26; 30) | ||
28 | NAME_REF@[26; 30) | ||
29 | IDENT@[26; 30) "path" | ||
30 | COLONCOLON@[30; 32) | ||
31 | USE_TREE_LIST@[32; 35) | ||
32 | L_CURLY@[32; 33) | ||
33 | USE_TREE@[33; 34) | ||
34 | STAR@[33; 34) | ||
35 | R_CURLY@[34; 35) | ||
36 | SEMI@[35; 36) | ||
37 | WHITESPACE@[36; 37) | ||
38 | USE_ITEM@[37; 59) | ||
39 | USE_KW@[37; 40) | ||
40 | WHITESPACE@[40; 41) | ||
41 | USE_TREE@[41; 58) | ||
42 | PATH@[41; 51) | ||
43 | PATH@[41; 45) | ||
44 | PATH_SEGMENT@[41; 45) | ||
45 | NAME_REF@[41; 45) | ||
46 | IDENT@[41; 45) "some" | ||
47 | COLONCOLON@[45; 47) | ||
48 | PATH_SEGMENT@[47; 51) | ||
49 | NAME_REF@[47; 51) | ||
50 | IDENT@[47; 51) "path" | ||
51 | COLONCOLON@[51; 53) | ||
52 | USE_TREE_LIST@[53; 58) | ||
53 | L_CURLY@[53; 54) | ||
54 | USE_TREE@[54; 57) | ||
55 | COLONCOLON@[54; 56) | ||
56 | STAR@[56; 57) | ||
57 | R_CURLY@[57; 58) | ||
58 | SEMI@[58; 59) | ||
59 | WHITESPACE@[59; 60) | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0117_use_tree_list_after_path.rs b/crates/ra_syntax/tests/data/parser/inline/0117_use_tree_list_after_path.rs new file mode 100644 index 000000000..c0a3d634e --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0117_use_tree_list_after_path.rs | |||
@@ -0,0 +1,2 @@ | |||
1 | use crate::{Item}; | ||
2 | use self::{Item}; | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0117_use_tree_list_after_path.txt b/crates/ra_syntax/tests/data/parser/inline/0117_use_tree_list_after_path.txt new file mode 100644 index 000000000..cac746e5b --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0117_use_tree_list_after_path.txt | |||
@@ -0,0 +1,37 @@ | |||
1 | SOURCE_FILE@[0; 37) | ||
2 | USE_ITEM@[0; 18) | ||
3 | USE_KW@[0; 3) | ||
4 | WHITESPACE@[3; 4) | ||
5 | USE_TREE@[4; 17) | ||
6 | PATH@[4; 9) | ||
7 | PATH_SEGMENT@[4; 9) | ||
8 | CRATE_KW@[4; 9) | ||
9 | COLONCOLON@[9; 11) | ||
10 | USE_TREE_LIST@[11; 17) | ||
11 | L_CURLY@[11; 12) | ||
12 | USE_TREE@[12; 16) | ||
13 | PATH@[12; 16) | ||
14 | PATH_SEGMENT@[12; 16) | ||
15 | NAME_REF@[12; 16) | ||
16 | IDENT@[12; 16) "Item" | ||
17 | R_CURLY@[16; 17) | ||
18 | SEMI@[17; 18) | ||
19 | WHITESPACE@[18; 19) | ||
20 | USE_ITEM@[19; 36) | ||
21 | USE_KW@[19; 22) | ||
22 | WHITESPACE@[22; 23) | ||
23 | USE_TREE@[23; 35) | ||
24 | PATH@[23; 27) | ||
25 | PATH_SEGMENT@[23; 27) | ||
26 | SELF_KW@[23; 27) | ||
27 | COLONCOLON@[27; 29) | ||
28 | USE_TREE_LIST@[29; 35) | ||
29 | L_CURLY@[29; 30) | ||
30 | USE_TREE@[30; 34) | ||
31 | PATH@[30; 34) | ||
32 | PATH_SEGMENT@[30; 34) | ||
33 | NAME_REF@[30; 34) | ||
34 | IDENT@[30; 34) "Item" | ||
35 | R_CURLY@[34; 35) | ||
36 | SEMI@[35; 36) | ||
37 | WHITESPACE@[36; 37) | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0118_use_tree_list.rs b/crates/ra_syntax/tests/data/parser/inline/0118_use_tree_list.rs new file mode 100644 index 000000000..06c387cee --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0118_use_tree_list.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) | ||
2 | use {path::from::root}; // Rust 2015 | ||
3 | use ::{some::arbritrary::path}; // Rust 2015 | ||
4 | use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/0118_use_tree_list.txt b/crates/ra_syntax/tests/data/parser/inline/0118_use_tree_list.txt new file mode 100644 index 000000000..89a0b9f2a --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/0118_use_tree_list.txt | |||
@@ -0,0 +1,135 @@ | |||
1 | SOURCE_FILE@[0; 250) | ||
2 | USE_ITEM@[0; 58) | ||
3 | USE_KW@[0; 3) | ||
4 | WHITESPACE@[3; 4) | ||
5 | USE_TREE@[4; 57) | ||
6 | USE_TREE_LIST@[4; 57) | ||
7 | L_CURLY@[4; 5) | ||
8 | USE_TREE@[5; 28) | ||
9 | PATH@[5; 28) | ||
10 | PATH@[5; 22) | ||
11 | PATH@[5; 16) | ||
12 | PATH@[5; 10) | ||
13 | PATH_SEGMENT@[5; 10) | ||
14 | CRATE_KW@[5; 10) | ||
15 | COLONCOLON@[10; 12) | ||
16 | PATH_SEGMENT@[12; 16) | ||
17 | NAME_REF@[12; 16) | ||
18 | IDENT@[12; 16) "path" | ||
19 | COLONCOLON@[16; 18) | ||
20 | PATH_SEGMENT@[18; 22) | ||
21 | NAME_REF@[18; 22) | ||
22 | IDENT@[18; 22) "from" | ||
23 | COLONCOLON@[22; 24) | ||
24 | PATH_SEGMENT@[24; 28) | ||
25 | NAME_REF@[24; 28) | ||
26 | IDENT@[24; 28) "root" | ||
27 | COMMA@[28; 29) | ||
28 | WHITESPACE@[29; 30) | ||
29 | USE_TREE@[30; 56) | ||
30 | PATH@[30; 56) | ||
31 | PATH@[30; 44) | ||
32 | PATH@[30; 38) | ||
33 | PATH@[30; 32) | ||
34 | PATH_SEGMENT@[30; 32) | ||
35 | NAME_REF@[30; 32) | ||
36 | IDENT@[30; 32) "or" | ||
37 | COLONCOLON@[32; 34) | ||
38 | PATH_SEGMENT@[34; 38) | ||
39 | NAME_REF@[34; 38) | ||
40 | IDENT@[34; 38) "path" | ||
41 | COLONCOLON@[38; 40) | ||
42 | PATH_SEGMENT@[40; 44) | ||
43 | NAME_REF@[40; 44) | ||
44 | IDENT@[40; 44) "from" | ||
45 | COLONCOLON@[44; 46) | ||
46 | PATH_SEGMENT@[46; 56) | ||
47 | NAME_REF@[46; 56) | ||
48 | IDENT@[46; 56) "crate_name" | ||
49 | R_CURLY@[56; 57) | ||
50 | SEMI@[57; 58) | ||
51 | WHITESPACE@[58; 59) | ||
52 | COMMENT@[59; 97) | ||
53 | WHITESPACE@[97; 98) | ||
54 | USE_ITEM@[98; 121) | ||
55 | USE_KW@[98; 101) | ||
56 | WHITESPACE@[101; 102) | ||
57 | USE_TREE@[102; 120) | ||
58 | USE_TREE_LIST@[102; 120) | ||
59 | L_CURLY@[102; 103) | ||
60 | USE_TREE@[103; 119) | ||
61 | PATH@[103; 119) | ||
62 | PATH@[103; 113) | ||
63 | PATH@[103; 107) | ||
64 | PATH_SEGMENT@[103; 107) | ||
65 | NAME_REF@[103; 107) | ||
66 | IDENT@[103; 107) "path" | ||
67 | COLONCOLON@[107; 109) | ||
68 | PATH_SEGMENT@[109; 113) | ||
69 | NAME_REF@[109; 113) | ||
70 | IDENT@[109; 113) "from" | ||
71 | COLONCOLON@[113; 115) | ||
72 | PATH_SEGMENT@[115; 119) | ||
73 | NAME_REF@[115; 119) | ||
74 | IDENT@[115; 119) "root" | ||
75 | R_CURLY@[119; 120) | ||
76 | SEMI@[120; 121) | ||
77 | WHITESPACE@[121; 122) | ||
78 | COMMENT@[122; 134) | ||
79 | WHITESPACE@[134; 135) | ||
80 | USE_ITEM@[135; 166) | ||
81 | USE_KW@[135; 138) | ||
82 | WHITESPACE@[138; 139) | ||
83 | USE_TREE@[139; 165) | ||
84 | COLONCOLON@[139; 141) | ||
85 | USE_TREE_LIST@[141; 165) | ||
86 | L_CURLY@[141; 142) | ||
87 | USE_TREE@[142; 164) | ||
88 | PATH@[142; 164) | ||
89 | PATH@[142; 158) | ||
90 | PATH@[142; 146) | ||
91 | PATH_SEGMENT@[142; 146) | ||
92 | NAME_REF@[142; 146) | ||
93 | IDENT@[142; 146) "some" | ||
94 | COLONCOLON@[146; 148) | ||
95 | PATH_SEGMENT@[148; 158) | ||
96 | NAME_REF@[148; 158) | ||
97 | IDENT@[148; 158) "arbritrary" | ||
98 | COLONCOLON@[158; 160) | ||
99 | PATH_SEGMENT@[160; 164) | ||
100 | NAME_REF@[160; 164) | ||
101 | IDENT@[160; 164) "path" | ||
102 | R_CURLY@[164; 165) | ||
103 | SEMI@[165; 166) | ||
104 | WHITESPACE@[166; 167) | ||
105 | COMMENT@[167; 179) | ||
106 | WHITESPACE@[179; 180) | ||
107 | USE_ITEM@[180; 206) | ||
108 | USE_KW@[180; 183) | ||
109 | WHITESPACE@[183; 184) | ||
110 | USE_TREE@[184; 205) | ||
111 | COLONCOLON@[184; 186) | ||
112 | USE_TREE_LIST@[186; 205) | ||
113 | L_CURLY@[186; 187) | ||
114 | USE_TREE@[187; 204) | ||
115 | USE_TREE_LIST@[187; 204) | ||
116 | L_CURLY@[187; 188) | ||
117 | USE_TREE@[188; 203) | ||
118 | USE_TREE_LIST@[188; 203) | ||
119 | L_CURLY@[188; 189) | ||
120 | USE_TREE@[189; 202) | ||
121 | PATH@[189; 202) | ||
122 | PATH@[189; 194) | ||
123 | PATH_SEGMENT@[189; 194) | ||
124 | CRATE_KW@[189; 194) | ||
125 | COLONCOLON@[194; 196) | ||
126 | PATH_SEGMENT@[196; 202) | ||
127 | NAME_REF@[196; 202) | ||
128 | IDENT@[196; 202) "export" | ||
129 | R_CURLY@[202; 203) | ||
130 | R_CURLY@[203; 204) | ||
131 | R_CURLY@[204; 205) | ||
132 | SEMI@[205; 206) | ||
133 | WHITESPACE@[206; 207) | ||
134 | COMMENT@[207; 249) | ||
135 | WHITESPACE@[249; 250) | ||