Skip to content

Commit e2c3ce5

Browse files
committed
Auto merge of #18226 - SabrinaJewson:fix-impl-use, r=Veykril
Correctly parse `use` in generic parameters Fixes: #18225
2 parents aacf840 + 22129b1 commit e2c3ce5

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn type_bound(p: &mut Parser<'_>) -> bool {
145145
T![for] => types::for_type(p, false),
146146
// test precise_capturing
147147
// fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
148-
T![use] => {
148+
T![use] if p.nth_at(1, T![<]) => {
149149
p.bump_any();
150150
generic_param_list(p)
151151
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
SOURCE_FILE
2+
IMPL
3+
IMPL_KW "impl"
4+
GENERIC_PARAM_LIST
5+
L_ANGLE "<"
6+
TYPE_PARAM
7+
NAME
8+
IDENT "T"
9+
COLON ":"
10+
WHITESPACE "\n"
11+
TYPE_BOUND_LIST
12+
ERROR
13+
USE_KW "use"
14+
WHITESPACE " "
15+
MACRO_CALL
16+
PATH
17+
PATH_SEGMENT
18+
NAME_REF
19+
IDENT "std"
20+
SEMICOLON ";"
21+
WHITESPACE "\n"
22+
error 8: expected R_ANGLE
23+
error 8: expected type
24+
error 11: expected `{`
25+
error 15: expected BANG
26+
error 15: expected `{`, `[`, `(`
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
impl<T:
2+
use std;

0 commit comments

Comments
 (0)