aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-pattern.cc
diff options
context:
space:
mode:
authorDave Evans <dave@dmetwo.org>2023-08-24 14:10:42 -0500
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:04:35 +0100
commit15648d5b8dc5a8cab1b11e14e5e5c178e32ed366 (patch)
tree42cff2553fe951d61233d3bcb0ab4299a3c003db /gcc/rust/backend/rust-compile-pattern.cc
parentbfc52efeac316de3797fc218df22d6eb0ef2a2b1 (diff)
downloadgcc-15648d5b8dc5a8cab1b11e14e5e5c178e32ed366.zip
gcc-15648d5b8dc5a8cab1b11e14e5e5c178e32ed366.tar.gz
gcc-15648d5b8dc5a8cab1b11e14e5e5c178e32ed366.tar.bz2
gccrs: Fix typechecking (and compilation) error for alt patterns in match expressions.
gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Add AltPattern visitor function * backend/rust-compile-pattern.h: Update CompilePatternCaseLabelExpr::visit(AltPattern&). * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Update AltPattern visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2431.rs: New test. Signed-off-by: Dave Evans <dave@dmetwo.org>
Diffstat (limited to 'gcc/rust/backend/rust-compile-pattern.cc')
-rw-r--r--gcc/rust/backend/rust-compile-pattern.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc
index 38fcedb..66726d2 100644
--- a/gcc/rust/backend/rust-compile-pattern.cc
+++ b/gcc/rust/backend/rust-compile-pattern.cc
@@ -104,6 +104,17 @@ CompilePatternCaseLabelExpr::visit (HIR::LiteralPattern &pattern)
case_label_expr = build_case_label (lit, NULL_TREE, associated_case_label);
}
+void
+CompilePatternCaseLabelExpr::visit (HIR::AltPattern &pattern)
+{
+ const auto &alts = pattern.get_alts ();
+ for (auto &alt_pattern : alts)
+ {
+ CompilePatternCaseLabelExpr::Compile (alt_pattern.get (),
+ associated_case_label, ctx);
+ }
+}
+
static tree
compile_range_pattern_bound (HIR::RangePatternBound *bound,
Analysis::NodeMapping mappings, location_t locus,