rust/tests/ui/pattern/rfc-3637-guard-patterns
Matthias Krüger af081a4247
Rollup merge of #141267 - dianne:fix-141265, r=oli-obk
only resolve top-level guard patterns' guards once

We resolve guard patterns' guards in `resolve_pattern_inner`, so to avoid resolving them multiple times, we must avoid doing so earlier. To accomplish this, `LateResolutionVisitor::visit_pat` contains a case for guard patterns that avoids visiting their guards while walking patterns.

This PR fixes #141265, which was due to `visit::walk_pat` being used instead; this meant guards at the top level of a pattern would be visited twice. e.g. it would ICE on `for x if x in [] {}`, but not `for (x if x) in [] {}`. `visit_pat` was already used for the guard pattern in the second example, on account of the top-level pattern being parens.
2025-05-21 15:38:08 +02:00
..
macro-rules.rs
name-resolution.rs name resolution for guard patterns 2025-05-18 04:21:57 -07:00
name-resolution.stderr name resolution for guard patterns 2025-05-18 04:21:57 -07:00
only-gather-locals-once.rs `gather_locals`: only visit guard pattern guards when checking the guard 2025-05-19 23:18:08 -07:00
only-resolve-top-level-guard-expr-once-ice-141265.rs only resolve top-level guard patterns' guards once 2025-05-19 18:02:54 -07:00
only-resolve-top-level-guard-expr-once-ice-141265.stderr only resolve top-level guard patterns' guards once 2025-05-19 18:02:54 -07:00