From 86679489effb0f88e0e073e48408d43b5c1f812c Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Wed, 9 Nov 2022 15:32:33 -0800 Subject: [PATCH] cranelift-isle: if-let patterns aren't root terms (#5233) The `is_root` flag to `translate_pattern` just determines whether the `rule_term` argument is used, which begs a larger cleanup. But that cleanup is less clear if `is_root` is set anywhere aside from the call in `collect_rules`. So I wanted to get confirmation that this particular use of that flag is incorrect first. These two arguments (`is_root` and `rule_term`) are used to prevent expansion of a term as an internal extractor ("macro") if: - that term is also an internal constructor - and it's the root term on the left-hand side of the current rule - and the pattern we're currently translating has no parents. I'm not sure what it should mean to use the term you're currently defining as the root pattern on the left-hand side of an if-let in the same rule, but I don't think it should have this particular special treatment. --- cranelift/isle/isle/src/sema.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cranelift/isle/isle/src/sema.rs b/cranelift/isle/isle/src/sema.rs index 7ef2e8142c..d869b0a7d1 100644 --- a/cranelift/isle/isle/src/sema.rs +++ b/cranelift/isle/isle/src/sema.rs @@ -2397,7 +2397,7 @@ impl TermEnv { &iflet.pattern, Some(ty), bindings, - /* is_root = */ true, + /* is_root = */ false, )?; Some(IfLet { lhs, rhs })