rust/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.rs
dianne ed983c2184 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 fixes an ICE due to `visit::walk_pat` being used instead, which
meant guards at the top level of a pattern would be visited twice.
2025-05-19 18:02:54 -07:00

13 lines
438 B
Rust

//! Regression test for <https://github.com/rust-lang/rust/issues/141265>.
//! Make sure expressions in top-level guard patterns are only resolved once.
fn main() {
for
else if b 0 {}
//~^ ERROR expected identifier, found keyword `else`
//~| ERROR missing `in` in `for` loop
//~| ERROR cannot find value `b` in this scope
//~| ERROR guard patterns are experimental
//~| ERROR `{integer}` is not an iterator
}