Commit Message
Arthur Cohen
Aug. 1, 2024, 2:55 p.m. UTC
From: Owen Avery <powerboat9.gamer@gmail.com> gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Reset is_let_top_level while visiting GroupedPattern. gcc/testsuite/ChangeLog: * rust/compile/let_alt.rs: Check for false positive. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com> --- gcc/rust/hir/rust-ast-lower-pattern.cc | 1 + gcc/testsuite/rust/compile/let_alt.rs | 1 + 2 files changed, 2 insertions(+)
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; }