From fc0addd1ffae33478cfc838f93e6685c0cbfa08c Mon Sep 17 00:00:00 2001 From: Mahmoud Mohamed Date: Wed, 15 Mar 2023 01:06:46 +0300 Subject: 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 --- gcc/rust/backend/rust-compile-expr.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 200f3a2..b2a8fab 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 ¶m_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++; } -- cgit v1.1