diff --git a/gcc/rust/hir/rust-ast-lower-pattern.cc b/gcc/rust/hir/rust-ast-lower-pattern.cc index a2228488ad2..d534b829517 100644 --- a/gcc/rust/hir/rust-ast-lower-pattern.cc +++ b/gcc/rust/hir/rust-ast-lower-pattern.cc @@ -276,6 +276,7 @@ ASTLoweringPattern::visit (AST::RangePattern &pattern) void ASTLoweringPattern::visit (AST::GroupedPattern &pattern) { + is_let_top_level = false; pattern.get_pattern_in_parens ()->accept_vis (*this); } diff --git a/gcc/testsuite/rust/compile/let_alt.rs b/gcc/testsuite/rust/compile/let_alt.rs index a2735bdbe77..ff16e6428ff 100644 --- a/gcc/testsuite/rust/compile/let_alt.rs +++ b/gcc/testsuite/rust/compile/let_alt.rs @@ -1,4 +1,5 @@ fn main() { let _a | _a = 12; // { dg-error "top level or-patterns are not allowed for .let. bindings" "" { target *-*-* } .-1 } + let (_b | _b) = 12; }