7234: Allow `true` and `false` keywords in const generics r=lnicola a=callym

This should fix #7232 - hopefully I've done it right, it passes the tests and the rast file looks like it's picking up the true and false in the test

Co-authored-by: Callym <hi@callym.com>
This commit is contained in:
bors[bot] 2021-01-10 14:06:03 +00:00 committed by GitHub
commit 8e54fa67cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View file

@ -26,7 +26,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
} }
// test type_arg // 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) { fn generic_arg(p: &mut Parser) {
let m = p.start(); let m = p.start();
match p.current() { match p.current() {
@ -55,6 +55,10 @@ fn generic_arg(p: &mut Parser) {
expressions::literal(p); expressions::literal(p);
m.complete(p, CONST_ARG); m.complete(p, CONST_ARG);
} }
TRUE_KW | FALSE_KW => {
expressions::literal(p);
m.complete(p, CONST_ARG);
}
_ => { _ => {
types::type_(p); types::type_(p);
m.complete(p, TYPE_ARG); m.complete(p, TYPE_ARG);

View file

@ -1,5 +1,5 @@
SOURCE_FILE@0..46 SOURCE_FILE@0..59
TYPE_ALIAS@0..45 TYPE_ALIAS@0..58
TYPE_KW@0..4 "type" TYPE_KW@0..4 "type"
WHITESPACE@4..5 " " WHITESPACE@4..5 " "
NAME@5..6 NAME@5..6
@ -7,12 +7,12 @@ SOURCE_FILE@0..46
WHITESPACE@6..7 " " WHITESPACE@6..7 " "
EQ@7..8 "=" EQ@7..8 "="
WHITESPACE@8..9 " " WHITESPACE@8..9 " "
PATH_TYPE@9..44 PATH_TYPE@9..57
PATH@9..44 PATH@9..57
PATH_SEGMENT@9..44 PATH_SEGMENT@9..57
NAME_REF@9..10 NAME_REF@9..10
IDENT@9..10 "B" IDENT@9..10 "B"
GENERIC_ARG_LIST@10..44 GENERIC_ARG_LIST@10..57
L_ANGLE@10..11 "<" L_ANGLE@10..11 "<"
LIFETIME_ARG@11..18 LIFETIME_ARG@11..18
LIFETIME@11..18 LIFETIME@11..18
@ -51,6 +51,16 @@ SOURCE_FILE@0..46
PATH_SEGMENT@40..43 PATH_SEGMENT@40..43
NAME_REF@40..43 NAME_REF@40..43
IDENT@40..43 "u64" IDENT@40..43 "u64"
R_ANGLE@43..44 ">" COMMA@43..44 ","
SEMICOLON@44..45 ";" WHITESPACE@44..45 " "
WHITESPACE@45..46 "\n" 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"

View file

@ -1 +1 @@
type A = B<'static, i32, 1, { 2 }, Item=u64>; type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;