aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-09-02 15:18:20 +0500
committerPhilip Herron <philip.herron@embecosm.com>2023-09-03 18:06:30 +0000
commit699f5257192ce8d9a856f4ee2779887aae6e92e9 (patch)
treedc3f1d6d49bc4b2e3e2828d417bff51705bc88f9
parent1f2dc6402de790f661a68b7a11a91d02eb366076 (diff)
downloadgcc-699f5257192ce8d9a856f4ee2779887aae6e92e9.zip
gcc-699f5257192ce8d9a856f4ee2779887aae6e92e9.tar.gz
gcc-699f5257192ce8d9a856f4ee2779887aae6e92e9.tar.bz2
gccrs: [E0532] Pattern arm did not match expected kind
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Added error code. gcc/testsuite/ChangeLog: * rust/compile/issue-2029.rs: Updated for dejagnu testcase. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-pattern.cc7
-rw-r--r--gcc/testsuite/rust/compile/issue-2029.rs2
2 files changed, 5 insertions, 4 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
index fd9cfd2..ea744a6 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
@@ -53,9 +53,10 @@ TypeCheckPattern::visit (HIR::TupleStructPattern &pattern)
TyTy::BaseType *pattern_ty = TypeCheckExpr::Resolve (&pattern.get_path ());
if (pattern_ty->get_kind () != TyTy::TypeKind::ADT)
{
- rust_error_at (pattern.get_locus (),
- "expected tuple struct/variant, found: %s",
- pattern_ty->get_name ().c_str ());
+ rust_error_at (
+ pattern.get_locus (), ErrorCode::E0532,
+ "expected tuple struct or tuple variant, found function %qs",
+ pattern_ty->get_name ().c_str ());
return;
}
diff --git a/gcc/testsuite/rust/compile/issue-2029.rs b/gcc/testsuite/rust/compile/issue-2029.rs
index 7856963..dab200d 100644
--- a/gcc/testsuite/rust/compile/issue-2029.rs
+++ b/gcc/testsuite/rust/compile/issue-2029.rs
@@ -6,7 +6,7 @@ fn foo(_: usize) -> Foo {
fn main() {
match Foo(true) {
foo(x)
- // { dg-error "expected tuple struct/variant, found" "" { target *-*-* } .-1 }
+ // { dg-error "expected tuple struct or tuple variant, found function " "" { target *-*-* } .-1 }
=> ()
}
}