diff options
| author | bors <bors@rust-lang.org> | 2022-05-07 10:53:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-07 10:53:37 +0000 |
| commit | 6f6e4efc3bc87f9259e011a5a6091b86a24ed41c (patch) | |
| tree | 8439e3bce52b7bc7cfa8a05dd6d7bf698d81b73d | |
| parent | 81b3e6d124db18cd6015b7d763addfd63e0bd54a (diff) | |
| parent | dbb066b99e2e644437ddecb20127bcfdba975614 (diff) | |
| download | rust-6f6e4efc3bc87f9259e011a5a6091b86a24ed41c.tar.gz rust-6f6e4efc3bc87f9259e011a5a6091b86a24ed41c.zip | |
Auto merge of #12185 - Veykril:parse-fix, r=Veykril
fix: Remap float parts as integers when parsed as indices cc https://github.com/rust-lang/rust-analyzer/pull/12149
| -rw-r--r-- | crates/parser/src/grammar.rs | 4 | ||||
| -rw-r--r-- | crates/parser/test_data/parser/inline/ok/0011_field_expr.rast | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 92f33025387..f68d7196c86 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -323,8 +323,8 @@ fn name_ref_or_index(p: &mut Parser) { p.at(IDENT) || p.at(INT_NUMBER) || p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST) ); let m = p.start(); - if p.at_ts(FLOAT_LITERAL_FIRST) { - p.bump_remap(FLOAT_NUMBER_PART); + if p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST) { + p.bump_remap(INT_NUMBER); } else { p.bump_any(); } diff --git a/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast b/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast index a1efb3a9fb2..19fab593fab 100644 --- a/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast +++ b/crates/parser/test_data/parser/inline/ok/0011_field_expr.rast @@ -50,7 +50,7 @@ SOURCE_FILE IDENT "x" DOT "." NAME_REF - FLOAT_NUMBER_PART "0" + INT_NUMBER "0" DOT "." WHITESPACE " " NAME_REF @@ -67,10 +67,10 @@ SOURCE_FILE IDENT "x" DOT "." NAME_REF - FLOAT_NUMBER_PART "0" + INT_NUMBER "0" DOT "." NAME_REF - FLOAT_NUMBER_PART "1" + INT_NUMBER "1" SEMICOLON ";" WHITESPACE "\n " EXPR_STMT |
