Skip to content

Commit

Permalink
Fix false positive for top-level AltPattern
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
powerboat9 authored and CohenArthur committed Feb 20, 2024
1 parent f2e1936 commit 5989e3d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcc/rust/hir/rust-ast-lower-pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions gcc/testsuite/rust/compile/let_alt.rs
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 5989e3d

Please sign in to comment.