Skip to content

Commit 8a28430

Browse files
committed
refactor: Rename and move const_arg_path
It wasn't testing the `const_arg` code path, it was actually hitting const_param's default value code path, so move it to the right place and rename it.
1 parent e84453c commit 8a28430

File tree

6 files changed

+41
-33
lines changed

6 files changed

+41
-33
lines changed

crates/parser/src/grammar/generic_args.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ pub(super) fn const_arg_expr(p: &mut Parser) {
9999
expressions::literal(p);
100100
lm.complete(p, PREFIX_EXPR);
101101
}
102-
// test const_arg_path
103-
// type T = S<u32::MAX>;
104102
_ => {
103+
// This shouldn't be hit by `const_arg`
105104
let lm = p.start();
106105
paths::use_path(p);
107106
lm.complete(p, PATH_EXPR);

crates/parser/src/grammar/generic_params.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ fn const_param(p: &mut Parser, m: Marker) {
8585

8686
// test const_param_default_expression
8787
// struct A<const N: i32 = { 1 }>;
88+
89+
// test const_param_default_path
90+
// struct A<const N: i32 = i32::MAX>;
8891
generic_args::const_arg_expr(p);
8992
}
9093

crates/parser/test_data/parser/inline/ok/0188_const_arg_path.rast

Lines changed: 0 additions & 30 deletions
This file was deleted.

crates/parser/test_data/parser/inline/ok/0188_const_arg_path.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
SOURCE_FILE
2+
STRUCT
3+
STRUCT_KW "struct"
4+
WHITESPACE " "
5+
NAME
6+
IDENT "A"
7+
GENERIC_PARAM_LIST
8+
L_ANGLE "<"
9+
CONST_PARAM
10+
CONST_KW "const"
11+
WHITESPACE " "
12+
NAME
13+
IDENT "N"
14+
COLON ":"
15+
WHITESPACE " "
16+
PATH_TYPE
17+
PATH
18+
PATH_SEGMENT
19+
NAME_REF
20+
IDENT "i32"
21+
WHITESPACE " "
22+
EQ "="
23+
WHITESPACE " "
24+
PATH_EXPR
25+
PATH
26+
PATH
27+
PATH_SEGMENT
28+
NAME_REF
29+
IDENT "i32"
30+
COLON2 "::"
31+
PATH_SEGMENT
32+
NAME_REF
33+
IDENT "MAX"
34+
R_ANGLE ">"
35+
SEMICOLON ";"
36+
WHITESPACE "\n"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct A<const N: i32 = i32::MAX>;

0 commit comments

Comments
 (0)