From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id BE4373858413; Wed, 21 Feb 2024 12:52:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE4373858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708519922; bh=adkwO4BM9yC/TSNNH6UXTpfcs9LHnzBBFdDRJ+fuBfI=; h=From:To:Subject:Date:From; b=eWOs6HKE6o8Xh4UymmLlXVwY1iPXl7OdfOnsFM1bRuV0yXnitWiA+/z/zaVAfFO+0 AT0oslcqUJMeM38a56fw6gCLhCQB4mUeR8aCauGv+ZH3Kp8Y+KAtQK3WSBD4sndIu/ AqEWt3AFlhjqQOS8CM+bR1QMdN3wnTVGidQJZX2o= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9112] gccrs: Fix lookup of TuplePattern sub-pattern types X-Act-Checkin: gcc X-Git-Author: Owen Avery X-Git-Refname: refs/heads/trunk X-Git-Oldrev: d7dde4ba49da7947d800fd7ab8e5a0e747073ead X-Git-Newrev: cdd76382414191134e0dabcc2c9f66f1df5472e7 Message-Id: <20240221125202.BE4373858413@sourceware.org> Date: Wed, 21 Feb 2024 12:52:02 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cdd76382414191134e0dabcc2c9f66f1df5472e7 commit r14-9112-gcdd76382414191134e0dabcc2c9f66f1df5472e7 Author: Owen Avery Date: Mon Feb 12 18:20:19 2024 -0500 gccrs: Fix lookup of TuplePattern sub-pattern types gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternLet::visit): Lookup type of sub-pattern, not tuple pattern itself. gcc/testsuite/ChangeLog: * rust/compile/issue-2847-b.rs: New test. Signed-off-by: Owen Avery Diff: --- gcc/rust/backend/rust-compile-pattern.cc | 12 ++++++------ gcc/testsuite/rust/compile/issue-2847-b.rs | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc index 4fa611f5383b..1a32f02c3ea3 100644 --- a/gcc/rust/backend/rust-compile-pattern.cc +++ b/gcc/rust/backend/rust-compile-pattern.cc @@ -678,8 +678,8 @@ CompilePatternLet::visit (HIR::TuplePattern &pattern) for (auto &sub : items_lower) { TyTy::BaseType *ty_sub = nullptr; - HirId pattern_id = pattern.get_mappings ().get_hirid (); - bool ok = ctx->get_tyctx ()->lookup_type (pattern_id, &ty_sub); + HirId sub_id = sub->get_mappings ().get_hirid (); + bool ok = ctx->get_tyctx ()->lookup_type (sub_id, &ty_sub); rust_assert (ok); tree sub_init @@ -697,8 +697,8 @@ CompilePatternLet::visit (HIR::TuplePattern &pattern) for (auto &sub : items_upper) { TyTy::BaseType *ty_sub = nullptr; - HirId pattern_id = pattern.get_mappings ().get_hirid (); - bool ok = ctx->get_tyctx ()->lookup_type (pattern_id, &ty_sub); + HirId sub_id = sub->get_mappings ().get_hirid (); + bool ok = ctx->get_tyctx ()->lookup_type (sub_id, &ty_sub); rust_assert (ok); tree sub_init @@ -719,8 +719,8 @@ CompilePatternLet::visit (HIR::TuplePattern &pattern) for (auto &sub : items.get_patterns ()) { TyTy::BaseType *ty_sub = nullptr; - HirId pattern_id = pattern.get_mappings ().get_hirid (); - bool ok = ctx->get_tyctx ()->lookup_type (pattern_id, &ty_sub); + HirId sub_id = sub->get_mappings ().get_hirid (); + bool ok = ctx->get_tyctx ()->lookup_type (sub_id, &ty_sub); rust_assert (ok); tree sub_init diff --git a/gcc/testsuite/rust/compile/issue-2847-b.rs b/gcc/testsuite/rust/compile/issue-2847-b.rs new file mode 100644 index 000000000000..ab2614210fca --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2847-b.rs @@ -0,0 +1,4 @@ +pub fn test() -> i32 { + let (a, _) = (1, 2); + a +}