diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index f94702e9742..c9941fe9303 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -129,7 +129,9 @@ fn opt_alias(p: &mut Parser) { if p.at(AS_KW) { let m = p.start(); p.bump(); - name(p); + if !p.eat(UNDERSCORE) { + name(p); + } m.complete(p, ALIAS); } } diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index 5111d37ebda..b366127263b 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs @@ -76,6 +76,7 @@ fn use_tree(p: &mut Parser) { // yet::another::path, // running::out::of::synonyms::for_::different::* // }; + // use Trait as _; opt_alias(p); } COLONCOLON => { diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.rs index 544caa02042..9be50f87708 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.rs @@ -5,3 +5,4 @@ yet::another::path, running::out::of::synonyms::for_::different::* }; +use Trait as _; diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.txt index 8ef0ecbc652..0c8dec81dcb 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0043_use_alias.txt @@ -1,4 +1,4 @@ -SOURCE_FILE@[0; 182) +SOURCE_FILE@[0; 198) USE_ITEM@[0; 28) USE_KW@[0; 3) WHITESPACE@[3; 4) @@ -121,3 +121,18 @@ SOURCE_FILE@[0; 182) R_CURLY@[179; 180) SEMI@[180; 181) WHITESPACE@[181; 182) + USE_ITEM@[182; 197) + USE_KW@[182; 185) + WHITESPACE@[185; 186) + USE_TREE@[186; 196) + PATH@[186; 191) + PATH_SEGMENT@[186; 191) + NAME_REF@[186; 191) + IDENT@[186; 191) "Trait" + WHITESPACE@[191; 192) + ALIAS@[192; 196) + AS_KW@[192; 194) + WHITESPACE@[194; 195) + UNDERSCORE@[195; 196) + SEMI@[196; 197) + WHITESPACE@[197; 198)