Skip to content

Commit 20f9f44

Browse files
committed
simplify pattern matching with trailing comma
Just accept any number of trailing commas. Simplifies the matching logic quite a bit!
1 parent 31ef461 commit 20f9f44

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

crates/formality-core/src/judgment.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ macro_rules! push_rules {
159159
};
160160

161161
if let Some(__JudgmentStruct($($input_names),*)) = Some($input_value) {
162-
$crate::push_rules!(@match inputs($($input_names)*) patterns($($patterns)*) args(@body ($judgment_name; $n; $v; $output); $($m)*));
162+
$crate::push_rules!(@match inputs($($input_names)*) patterns($($patterns)*,) args(@body ($judgment_name; $n; $v; $output); $($m)*));
163163
}
164164
}
165165
};
@@ -198,40 +198,19 @@ macro_rules! push_rules {
198198
}
199199
};
200200

201-
(@match inputs($in0:ident $($inputs:tt)*) patterns($pat0:ident : $ty0:ty) args $args:tt) => {
202-
{
203-
if let Some($pat0) = $crate::Downcast::downcast::<$ty0>($in0) {
204-
$crate::push_rules!(@match inputs($($inputs)*) patterns() args $args);
205-
}
206-
}
207-
};
208-
209201
(@match inputs($in0:ident $($inputs:tt)*) patterns($pat0:ident, $($pats:tt)*) args $args:tt) => {
210202
{
211203
let $pat0 = Clone::clone($in0);
212204
$crate::push_rules!(@match inputs($($inputs)*) patterns($($pats)*) args $args);
213205
}
214206
};
215207

216-
(@match inputs($in0:ident $($inputs:tt)*) patterns($pat0:ident) args $args:tt) => {
217-
{
218-
let $pat0 = Clone::clone($in0);
219-
$crate::push_rules!(@match inputs($($inputs)*) patterns() args $args);
220-
}
221-
};
222-
223208
(@match inputs($in0:ident $($inputs:tt)*) patterns($pat0:pat, $($pats:tt)*) args $args:tt) => {
224209
if let Some($pat0) = $crate::Downcast::downcast(&$in0) {
225210
$crate::push_rules!(@match inputs($($inputs)*) patterns($($pats)*) args $args);
226211
}
227212
};
228213

229-
(@match inputs($in0:ident $($inputs:tt)*) patterns($pat0:pat) args $args:tt) => {
230-
if let Some($pat0) = $crate::Downcast::downcast(&$in0) {
231-
$crate::push_rules!(@match inputs($($inputs)*) patterns() args $args);
232-
}
233-
};
234-
235214
// (@match (($arg0:ident @ $pat0:pat) $($args:tt)*) ($n:literal; $v:expr; $output:ident) $($m:tt)*) => {
236215
// if let Some($pat0) = $crate::cast::Downcast::downcast(&$arg0) {
237216
// $crate::push_rules!(@match ($($args)*) ($n; $v; $output) $($m)*);

0 commit comments

Comments
 (0)