about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/parser/src/grammar/type_args.rs9
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rast30
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rs1
3 files changed, 40 insertions, 0 deletions
diff --git a/crates/parser/src/grammar/type_args.rs b/crates/parser/src/grammar/type_args.rs
index 42cd426bd7b..56266b8d479 100644
--- a/crates/parser/src/grammar/type_args.rs
+++ b/crates/parser/src/grammar/type_args.rs
@@ -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);
diff --git a/crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rast b/crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rast
new file mode 100644
index 00000000000..b20e523dc1b
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rast
@@ -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"
diff --git a/crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rs b/crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rs
new file mode 100644
index 00000000000..8a81d05cd94
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0164_const_generic_negated_literal.rs
@@ -0,0 +1 @@
+fn f() { S::<-1> }