Skip to content

PmCheck: Use guard tree variants that more closely mirror source syntax (#18565)

Sebastian Graf requested to merge wip/T18565 into master

Previously, we desugared and coverage checked plain guard trees as described in Lower Your Guards. That caused (in !3849 (closed)) quite a bit of pain when we need to partially recover tree structure of the input syntax to return covered sets for long-distance information, for example.

In this refactor, I introduced a guard tree variant for each relevant source syntax component of a pattern-match (mainly match groups, match, GRHS, empty case, pattern binding). I made sure to share as much coverage checking code as possible, so that the syntax-specific checking functions are just wrappers around the more substantial checking functions for the LYG primitives (checkSequence, checkGrds).

The refactoring payed off in clearer code and elimination of all panics related to assumed guard tree structure and thus fixes #18565 (closed).

I also took the liberty to rename and re-arrange the order of functions and comments in the module, deleted some dead and irrelevant Notes, wrote some new ones and gave an overview module haddock.

I also snuck in a fix for #18572 (closed) as a prequel commit.

Merge request reports