diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-09-05 15:23:28 +0200 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2024-09-05 17:07:10 +0200 |
| commit | 4e2e1bf6edc75a75bfb86c912c6f1c23672e531c (patch) | |
| tree | 24d7225fd8ac65b01e1b9823f38e9f312b9ffe99 | |
| parent | 20e9c8d110d6259b8086c2ffd6268d0dd072a2ab (diff) | |
| download | rust-4e2e1bf6edc75a75bfb86c912c6f1c23672e531c.tar.gz rust-4e2e1bf6edc75a75bfb86c912c6f1c23672e531c.zip | |
fix: Fix parser panicking on invalid asm options
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-ty/src/tests/macros.rs | 5 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/macros.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/macros.rs index 10ab6d3ff89..53b69c12f05 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/macros.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/macros.rs @@ -1498,6 +1498,11 @@ fn main() { 43..44 '1': i32 58..63 'mut o': i32 66..67 '0': i32 + !95..104 'thread_id': usize + !103..107 '&foo': &'? i32 + !104..107 'foo': i32 + !115..120 '&muto': &'? mut i32 + !119..120 'o': i32 293..294 'o': i32 308..317 'thread_id': usize "#]], diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs index a1a3e947092..2333e6c862b 100644 --- a/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs +++ b/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs @@ -434,6 +434,7 @@ fn parse_options(p: &mut Parser<'_>) { let m = p.start(); if !OPTIONS.iter().any(|&syntax| p.eat_contextual_kw(syntax)) { p.err_and_bump("expected asm option"); + m.abandon(p); continue; } m.complete(p, ASM_OPTION); |
