handle match scrutinee in closure captures

This commit is contained in:
hkalbasi 2023-05-19 12:00:19 +03:30
parent e8ae2d3976
commit c5ea2d7adc
8 changed files with 137 additions and 10 deletions

View file

@ -221,15 +221,15 @@ impl Body {
pub fn walk_bindings_in_pat(&self, pat_id: PatId, mut f: impl FnMut(BindingId)) {
self.walk_pats(pat_id, &mut |pat| {
if let Pat::Bind { id, .. } = pat {
if let Pat::Bind { id, .. } = &self[pat] {
f(*id);
}
});
}
pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(&Pat)) {
pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(PatId)) {
let pat = &self[pat_id];
f(pat);
f(pat_id);
match pat {
Pat::Range { .. }
| Pat::Lit(..)