aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2024-02-12 18:20:19 -0500
committerCohenArthur <arthur.cohen@embecosm.com>2024-02-13 15:08:02 +0000
commita4716752fbb9eb7a06d408c98de42a2aec944713 (patch)
treed6edca3476cbb9bc69e448bda84b94adfb5f14de /gcc
parent50f8ca9800442165bddc142051c08b9394768dd4 (diff)
downloadgcc-a4716752fbb9eb7a06d408c98de42a2aec944713.zip
gcc-a4716752fbb9eb7a06d408c98de42a2aec944713.tar.gz
gcc-a4716752fbb9eb7a06d408c98de42a2aec944713.tar.bz2
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 <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-pattern.cc12
-rw-r--r--gcc/testsuite/rust/compile/issue-2847-b.rs4
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 810cf6b..df60fc0 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 0000000..ab26142
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2847-b.rs
@@ -0,0 +1,4 @@
+pub fn test() -> i32 {
+ let (a, _) = (1, 2);
+ a
+}