From 5b79d922b2b2704a89891d62e262df8b580bbd88 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 5 Sep 2024 15:23:28 +0200 Subject: [PATCH] fix: Fix parser panicking on invalid asm options --- crates/hir-ty/src/tests/macros.rs | 5 +++++ crates/parser/src/grammar/expressions/atom.rs | 1 + 2 files changed, 6 insertions(+) diff --git a/crates/hir-ty/src/tests/macros.rs b/crates/hir-ty/src/tests/macros.rs index 10ab6d3ff8..53b69c12f0 100644 --- a/crates/hir-ty/src/tests/macros.rs +++ b/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/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index a1a3e94709..2333e6c862 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/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);