mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Correctly parse negated literals as const args
This commit is contained in:
parent
49b219b103
commit
caee3a2eeb
3 changed files with 40 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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"
|
|
@ -0,0 +1 @@
|
|||
fn f() { S::<-1> }
|
Loading…
Reference in a new issue