diff --git a/crates/parser/src/grammar/type_args.rs b/crates/parser/src/grammar/type_args.rs index a013c49b9a..debb23fea1 100644 --- a/crates/parser/src/grammar/type_args.rs +++ b/crates/parser/src/grammar/type_args.rs @@ -26,7 +26,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) { } // test type_arg -// type A = B<'static, i32, 1, { 2 }, Item=u64>; +// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>; fn generic_arg(p: &mut Parser) { let m = p.start(); match p.current() { @@ -55,6 +55,10 @@ fn generic_arg(p: &mut Parser) { expressions::literal(p); m.complete(p, CONST_ARG); } + TRUE_KW | FALSE_KW => { + expressions::literal(p); + m.complete(p, CONST_ARG); + } _ => { types::type_(p); m.complete(p, TYPE_ARG); diff --git a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast index 51e881a8e2..68c0f1c668 100644 --- a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast +++ b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast @@ -1,5 +1,5 @@ -SOURCE_FILE@0..46 - TYPE_ALIAS@0..45 +SOURCE_FILE@0..59 + TYPE_ALIAS@0..58 TYPE_KW@0..4 "type" WHITESPACE@4..5 " " NAME@5..6 @@ -7,12 +7,12 @@ SOURCE_FILE@0..46 WHITESPACE@6..7 " " EQ@7..8 "=" WHITESPACE@8..9 " " - PATH_TYPE@9..44 - PATH@9..44 - PATH_SEGMENT@9..44 + PATH_TYPE@9..57 + PATH@9..57 + PATH_SEGMENT@9..57 NAME_REF@9..10 IDENT@9..10 "B" - GENERIC_ARG_LIST@10..44 + GENERIC_ARG_LIST@10..57 L_ANGLE@10..11 "<" LIFETIME_ARG@11..18 LIFETIME@11..18 @@ -51,6 +51,16 @@ SOURCE_FILE@0..46 PATH_SEGMENT@40..43 NAME_REF@40..43 IDENT@40..43 "u64" - R_ANGLE@43..44 ">" - SEMICOLON@44..45 ";" - WHITESPACE@45..46 "\n" + COMMA@43..44 "," + WHITESPACE@44..45 " " + CONST_ARG@45..49 + LITERAL@45..49 + TRUE_KW@45..49 "true" + COMMA@49..50 "," + WHITESPACE@50..51 " " + CONST_ARG@51..56 + LITERAL@51..56 + FALSE_KW@51..56 "false" + R_ANGLE@56..57 ">" + SEMICOLON@57..58 ";" + WHITESPACE@58..59 "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs index 0d07d76514..6a8721a73e 100644 --- a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs +++ b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs @@ -1 +1 @@ -type A = B<'static, i32, 1, { 2 }, Item=u64>; +type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;