8684: Correctly parse negated literals as const args r=jonas-schievink a=jonas-schievink

Previously we didn't accept `S::<-0>;`

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2021-04-29 00:28:27 +00:00 committed by GitHub
commit 9d199486da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View File

@ -59,6 +59,15 @@ fn generic_arg(p: &mut Parser) {
expressions::literal(p);
m.complete(p, CONST_ARG);
}
// test const_generic_negated_literal
// fn f() { S::<-1> }
T![-] => {
let lm = p.start();
p.bump(T![-]);
expressions::literal(p);
lm.complete(p, PREFIX_EXPR);
m.complete(p, CONST_ARG);
}
_ => {
types::type_(p);
m.complete(p, TYPE_ARG);

View File

@ -0,0 +1,30 @@
SOURCE_FILE@0..19
FN@0..18
FN_KW@0..2 "fn"
WHITESPACE@2..3 " "
NAME@3..4
IDENT@3..4 "f"
PARAM_LIST@4..6
L_PAREN@4..5 "("
R_PAREN@5..6 ")"
WHITESPACE@6..7 " "
BLOCK_EXPR@7..18
L_CURLY@7..8 "{"
WHITESPACE@8..9 " "
PATH_EXPR@9..16
PATH@9..16
PATH_SEGMENT@9..16
NAME_REF@9..10
IDENT@9..10 "S"
GENERIC_ARG_LIST@10..16
COLON2@10..12 "::"
L_ANGLE@12..13 "<"
CONST_ARG@13..15
PREFIX_EXPR@13..15
MINUS@13..14 "-"
LITERAL@14..15
INT_NUMBER@14..15 "1"
R_ANGLE@15..16 ">"
WHITESPACE@16..17 " "
R_CURLY@17..18 "}"
WHITESPACE@18..19 "\n"

View File

@ -0,0 +1 @@
fn f() { S::<-1> }