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.
This commit is contained in:
Jamey Sharp
2022-11-09 15:32:33 -08:00
committed by GitHub
parent 54998715ea
commit 86679489ef

View File

@@ -2397,7 +2397,7 @@ impl TermEnv {
&iflet.pattern, &iflet.pattern,
Some(ty), Some(ty),
bindings, bindings,
/* is_root = */ true, /* is_root = */ false,
)?; )?;
Some(IfLet { lhs, rhs }) Some(IfLet { lhs, rhs })