diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index d649a0e3c9..a329408439 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -22,7 +22,8 @@ fn compile<'a>(raw_branches: Vec<(Guard<'a>, Pattern<'a>, u64)>) -> DecisionTree .into_iter() .map(|(guard, pattern, index)| Branch { goal: index, - patterns: vec![(Vec::new(), guard, pattern)], + guard, + patterns: vec![(Vec::new(), pattern)], }) .collect(); @@ -156,7 +157,8 @@ impl<'a> Hash for GuardedTest<'a> { #[derive(Clone, Debug, PartialEq)] struct Branch<'a> { goal: Label, - patterns: Vec<(Vec, Guard<'a>, Pattern<'a>)>, + guard: Guard<'a>, + patterns: Vec<(Vec, Pattern<'a>)>, } fn to_decision_tree(raw_branches: Vec) -> DecisionTree { @@ -231,16 +233,16 @@ fn flatten_patterns(branch: Branch) -> Branch { } Branch { - goal: branch.goal, patterns: result, + ..branch } } fn flatten<'a>( - path_pattern: (Vec, Guard<'a>, Pattern<'a>), - path_patterns: &mut Vec<(Vec, Guard<'a>, Pattern<'a>)>, + path_pattern: (Vec, Pattern<'a>), + path_patterns: &mut Vec<(Vec, Pattern<'a>)>, ) { - match path_pattern.2 { + match path_pattern.1 { Pattern::AppliedTag { union, arguments, @@ -257,7 +259,6 @@ fn flatten<'a>( // NOTE here elm will unbox, but we don't use that path_patterns.push(( path, - path_pattern.1.clone(), Pattern::AppliedTag { union, arguments, @@ -274,15 +275,7 @@ fn flatten<'a>( tag_id, }); - flatten( - ( - new_path, - // same guard here? - path_pattern.1.clone(), - arg_pattern.clone(), - ), - path_patterns, - ); + flatten((new_path, arg_pattern.clone()), path_patterns); } } } @@ -301,11 +294,11 @@ fn flatten<'a>( /// us something like ("x" => value.0.0) fn check_for_match(branches: &[Branch]) -> Option