mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00

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.
13 lines
438 B
Rust
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
|
|
}
|