aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
diff options
context:
space:
mode:
authorMahmoud Mohamed <mahadelr19@gmail.com>2023-03-15 01:06:46 +0300
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:21:10 +0100
commit1b793f2aa1ad1d64ff2f7508375a407a6d9e7788 (patch)
treed5d61f522b521377baabef56e5f486c0fac69a17 /gcc/rust/backend/rust-compile-expr.cc
parent69cc35db87d0505418a898a80180f5a843682b35 (diff)
downloadgcc-1b793f2aa1ad1d64ff2f7508375a407a6d9e7788.zip
gcc-1b793f2aa1ad1d64ff2f7508375a407a6d9e7788.tar.gz
gcc-1b793f2aa1ad1d64ff2f7508375a407a6d9e7788.tar.bz2
gccrs: hir: Improve pattern bindings handling in closure parameters
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): handle closure parameters pattern bindings using CompilePatternBindings visitor gcc/testsuite/ChangeLog: * rust/execute/torture/closure4.rs: New test. * rust/execute/torture/ref-pattern2.rs: New test. Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 1a98f4a..3d47d43 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -2918,9 +2918,8 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr,
tree compiled_param_var = ctx->get_backend ()->struct_field_expression (
args_param_expr, i, closure_param.get_locus ());
- const HIR::Pattern &param_pattern = *closure_param.get_pattern ();
- ctx->insert_pattern_binding (
- param_pattern.get_pattern_mappings ().get_hirid (), compiled_param_var);
+ CompilePatternBindings::Compile (closure_param.get_pattern ().get (),
+ compiled_param_var, ctx);
i++;
}