aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-pattern.h
diff options
context:
space:
mode:
authorMahmoud Mohamed <mahadelr19@gmail.com>2023-03-08 02:57:24 +0300
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:21:09 +0100
commit3e0437dc981af591f46234fd2e3aebb3c60028cc (patch)
treec92aeda15be2c1ba1afd93779e6efc1b1c33fa02 /gcc/rust/backend/rust-compile-pattern.h
parenteba557860627a8ce1bb37d1427469db99cb0c059 (diff)
downloadgcc-3e0437dc981af591f46234fd2e3aebb3c60028cc.zip
gcc-3e0437dc981af591f46234fd2e3aebb3c60028cc.tar.gz
gcc-3e0437dc981af591f46234fd2e3aebb3c60028cc.tar.bz2
gccrs: hir: Provide basic handling for ReferencePattern in function parameter
Added an implementation for `CompilePatternBindings::visit (HIR::ReferencePattern)` where we dereference the initial expression and recurse. Added an implementation for `CompilePatternBindings::visit (HIR::IdentifierPattern)` as well since it's the simplest base case. In addition to this, a small refactor for the shared code in `StructPattern` and `TupleStructPattern` visits was added as a helper function called `create_tmp_param_var`. gcc/rust/ChangeLog: * backend/rust-compile-fnparam.cc (CompileFnParam::visit): Added visit implementation for ReferencePattern. (CompileFnParam::create_tmp_param_var): Refactored duplicated code into a helper function. * backend/rust-compile-fnparam.h: Added visit implementation for ReferencePattern. * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): Added visit implementation for ReferencePattern and IdentifierPattern. * backend/rust-compile-pattern.h: Added visit implementation for ReferencePattern and IdentifierPattern. gcc/testsuite/ChangeLog: * rust/compile/ref_pattern_fn_param.rs: Moved to... * rust/compile/ref_pattern_fn_param1.rs: ...here. * rust/compile/ref_pattern_fn_param2.rs: New test. * rust/execute/torture/ref-pattern1.rs: New test. Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-pattern.h')
-rw-r--r--gcc/rust/backend/rust-compile-pattern.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-pattern.h b/gcc/rust/backend/rust-compile-pattern.h
index a7bd115..3fba9c5 100644
--- a/gcc/rust/backend/rust-compile-pattern.h
+++ b/gcc/rust/backend/rust-compile-pattern.h
@@ -76,6 +76,8 @@ public:
void visit (HIR::StructPattern &pattern) override;
void visit (HIR::TupleStructPattern &pattern) override;
+ void visit (HIR::ReferencePattern &pattern) override;
+ void visit (HIR::IdentifierPattern &) override;
// unsupported
void visit (HIR::AltPattern &pattern) override
@@ -85,12 +87,10 @@ public:
}
// Empty visit for unused Pattern HIR nodes.
- void visit (HIR::IdentifierPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
void visit (HIR::PathInExpression &) override {}
void visit (HIR::QualifiedPathInExpression &) override {}
void visit (HIR::RangePattern &) override {}
- void visit (HIR::ReferencePattern &) override {}
void visit (HIR::SlicePattern &) override {}
void visit (HIR::TuplePattern &) override {}
void visit (HIR::WildcardPattern &) override {}