Skip to content

Commit

Permalink
doesn't compile - missing self deconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
skius committed Aug 9, 2023
1 parent 7848f09 commit 512b158
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
33 changes: 22 additions & 11 deletions experimental/transliterator_parser/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,19 @@ struct Pass1Data {
used_transliterators: HashSet<parse::BasicId>,
}

#[derive(Debug, Clone)]
struct DirectedPass1Result<'p> {
// data with dependencies resolved and counts summed
data: Pass1Data,
groups: RuleGroups<'p>,
filter: Option<UnicodeSet>,
}

#[allow(unused)] // TODO: remove annotation
#[derive(Debug, Clone)]
struct Pass1Result<'p> {
// data with dependencies resolved and counts summed
forward_data: Pass1Data,
reverse_data: Pass1Data,
forward_groups: RuleGroups<'p>,
reverse_groups: RuleGroups<'p>,
forward_result: DirectedPass1Result<'p>,
reverse_result: DirectedPass1Result<'p>,
variable_definitions: HashMap<String, &'p [parse::Element]>,
}

Expand Down Expand Up @@ -758,11 +763,17 @@ impl Pass1ResultGenerator {
let reverse_rule_groups = pass.reverse_rule_group_agg.finalize();

Ok(Pass1Result {
forward_data,
reverse_data,
forward_result: DirectedPass1Result {
data: forward_data,
filter: pass.forward_filter,
groups: forward_rule_groups,
},
reverse_result: DirectedPass1Result {
data: reverse_data,
filter: pass.reverse_filter,
groups: reverse_rule_groups,
},
variable_definitions,
forward_groups: forward_rule_groups,
reverse_groups: reverse_rule_groups,
})
}

Expand Down Expand Up @@ -1098,8 +1109,8 @@ mod tests {
rev_counts,
);

assert_eq!(fwd_data, result.forward_data);
assert_eq!(rev_data, result.reverse_data);
assert_eq!(fwd_data, result.forward_result.data);
assert_eq!(rev_data, result.reverse_result.data);

let actual_definition_keys: HashSet<_> = result
.variable_definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ impl<'p> ReverseRuleGroup<'p> {
group.push_back(rule);
None
}
(Self::Conversion(_), UniRule::Transform(new_rule)) => {
Some(std::mem::replace(self, Self::new_transform(new_rule)))
(curr @ Self::Conversion(_), UniRule::Transform(new_rule)) => {
Some(std::mem::replace(curr, Self::new_transform(new_rule)))
}
(Self::Transform(_), UniRule::Conversion(new_rule)) => {
Some(std::mem::replace(self, Self::new_conversion(new_rule)))
(curr @ Self::Transform(_), UniRule::Conversion(new_rule)) => {
Some(std::mem::replace(curr, Self::new_conversion(new_rule)))
}
}
}
Expand Down

0 comments on commit 512b158

Please sign in to comment.