From b2492874bcd71bd1bfeaf98a799a43bf4ff4e87b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 20 Feb 2023 13:39:31 -0800 Subject: [PATCH] Support const block syntax in ensure! macro --- src/ensure.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ensure.rs b/src/ensure.rs index 0ab4471..c40cb92 100644 --- a/src/ensure.rs +++ b/src/ensure.rs @@ -231,6 +231,11 @@ macro_rules! __parse_ensure { $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $unsafe $block) $($parse)*} ($($rest)*) $($rest)*) }; + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($const:tt $block:tt $($dup:tt)*) const {$($body:tt)*} $($rest:tt)*) => { + // TODO: this is mostly useless due to https://github.com/rust-lang/rust/issues/86730 + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $const $block) $($parse)*} ($($rest)*) $($rest)*) + }; + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $lit:literal $($rest:tt)*) => { $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $lit) $($parse)*} ($($rest)*) $($rest)*) };