From 444a119220b8fe2c5ddf996b2a00cb67e375587d Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sat, 30 Mar 2019 13:44:58 +0200 Subject: Fix parsing <= in type_args --- crates/ra_parser/src/grammar/expressions.rs | 1 + crates/ra_parser/src/grammar/type_args.rs | 1 + .../tests/data/parser/inline/ok/0029_cast_expr.rs | 1 + .../tests/data/parser/inline/ok/0029_cast_expr.txt | 32 ++++++++++++++++++---- 4 files changed, 29 insertions(+), 6 deletions(-) (limited to 'crates') diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 73e1acd5a..bf5d6544d 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -410,6 +410,7 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { // 82 as i32; // 81 as i8 + 1; // 79 as i16 - 1; +// 0x36 as u8 <= 0x37; // } fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { assert!(p.at(AS_KW)); diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs index f889419c5..684976b99 100644 --- a/crates/ra_parser/src/grammar/type_args.rs +++ b/crates/ra_parser/src/grammar/type_args.rs @@ -8,6 +8,7 @@ pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) { p.bump(); p.bump(); } + (false, L_ANGLE, EQ) => return, (false, L_ANGLE, _) => { m = p.start(); p.bump(); diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.rs index b571a5860..bfe8e4b36 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.rs @@ -2,4 +2,5 @@ fn foo() { 82 as i32; 81 as i8 + 1; 79 as i16 - 1; + 0x36 as u8 <= 0x37; } diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.txt index cb56aef0b..875ed1abd 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0029_cast_expr.txt @@ -1,5 +1,5 @@ -SOURCE_FILE@[0; 65) - FN_DEF@[0; 64) +SOURCE_FILE@[0; 89) + FN_DEF@[0; 88) FN_KW@[0; 2) WHITESPACE@[2; 3) NAME@[3; 6) @@ -8,7 +8,7 @@ SOURCE_FILE@[0; 65) L_PAREN@[6; 7) R_PAREN@[7; 8) WHITESPACE@[8; 9) - BLOCK@[9; 64) + BLOCK@[9; 88) L_CURLY@[9; 10) WHITESPACE@[10; 15) EXPR_STMT@[15; 25) @@ -64,6 +64,26 @@ SOURCE_FILE@[0; 65) LITERAL@[60; 61) INT_NUMBER@[60; 61) "1" SEMI@[61; 62) - WHITESPACE@[62; 63) - R_CURLY@[63; 64) - WHITESPACE@[64; 65) + WHITESPACE@[62; 67) + EXPR_STMT@[67; 86) + BIN_EXPR@[67; 85) + CAST_EXPR@[67; 77) + LITERAL@[67; 71) + INT_NUMBER@[67; 71) "0x36" + WHITESPACE@[71; 72) + AS_KW@[72; 74) + WHITESPACE@[74; 75) + PATH_TYPE@[75; 77) + PATH@[75; 77) + PATH_SEGMENT@[75; 77) + NAME_REF@[75; 77) + IDENT@[75; 77) "u8" + WHITESPACE@[77; 78) + LTEQ@[78; 80) + WHITESPACE@[80; 81) + LITERAL@[81; 85) + INT_NUMBER@[81; 85) "0x37" + SEMI@[85; 86) + WHITESPACE@[86; 87) + R_CURLY@[87; 88) + WHITESPACE@[88; 89) -- cgit v1.2.3