From 9d99eff6f90522a838551326e651bb6b660ca624 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Thu, 15 Sep 2022 10:40:37 -0700 Subject: [PATCH] Flatten `and` patterns in ISLE (#4915) Flatten nested and patterns into a single vector in the ISLE front-end. --- cranelift/isle/isle/src/sema.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cranelift/isle/isle/src/sema.rs b/cranelift/isle/isle/src/sema.rs index 3da2441ed4..68c20097c0 100644 --- a/cranelift/isle/isle/src/sema.rs +++ b/cranelift/isle/isle/src/sema.rs @@ -1514,7 +1514,12 @@ impl TermEnv { /* is_root = */ false, )); expected_ty = expected_ty.or(Some(ty)); - children.push(subpat); + + // Normalize nested `And` nodes to a single vector of conjuncts. + match subpat { + Pattern::And(_, subpat_children) => children.extend(subpat_children), + _ => children.push(subpat), + } } if expected_ty.is_none() { tyenv.report_error(pos, "No type for (and ...) form.".to_string());