Skip to content

Commit 11e0851

Browse files
bors[bot]matklad
andcommitted
Merge #927
927: allow aliases in underscores r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents dc8bcc1 + 0a19f4f commit 11e0851

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

crates/ra_parser/src/grammar.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ fn opt_alias(p: &mut Parser) {
129129
if p.at(AS_KW) {
130130
let m = p.start();
131131
p.bump();
132-
name(p);
132+
if !p.eat(UNDERSCORE) {
133+
name(p);
134+
}
133135
m.complete(p, ALIAS);
134136
}
135137
}

crates/ra_parser/src/grammar/items/use_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fn use_tree(p: &mut Parser) {
7676
// yet::another::path,
7777
// running::out::of::synonyms::for_::different::*
7878
// };
79+
// use Trait as _;
7980
opt_alias(p);
8081
}
8182
COLONCOLON => {

crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ use some::{
55
yet::another::path,
66
running::out::of::synonyms::for_::different::*
77
};
8+
use Trait as _;

crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SOURCE_FILE@[0; 182)
1+
SOURCE_FILE@[0; 198)
22
USE_ITEM@[0; 28)
33
USE_KW@[0; 3)
44
WHITESPACE@[3; 4)
@@ -121,3 +121,18 @@ SOURCE_FILE@[0; 182)
121121
R_CURLY@[179; 180)
122122
SEMI@[180; 181)
123123
WHITESPACE@[181; 182)
124+
USE_ITEM@[182; 197)
125+
USE_KW@[182; 185)
126+
WHITESPACE@[185; 186)
127+
USE_TREE@[186; 196)
128+
PATH@[186; 191)
129+
PATH_SEGMENT@[186; 191)
130+
NAME_REF@[186; 191)
131+
IDENT@[186; 191) "Trait"
132+
WHITESPACE@[191; 192)
133+
ALIAS@[192; 196)
134+
AS_KW@[192; 194)
135+
WHITESPACE@[194; 195)
136+
UNDERSCORE@[195; 196)
137+
SEMI@[196; 197)
138+
WHITESPACE@[197; 198)

0 commit comments

Comments
 (0)