Skip to content

Commit 67d1f4a

Browse files
MahadMuhammadP-E-P
authored andcommitted
gccrs: [E0308] array misamatch types
gcc/rust/ChangeLog: * backend/rust-compile.cc (HIRCompileBase::verify_array_capacities): Added ErrorCode. gcc/testsuite/ChangeLog: * rust/compile/arrays2.rs: changed comment to pass testcase. Signed-off-by: Muhammad Mahad <[email protected]>
1 parent a584856 commit 67d1f4a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

gcc/rust/backend/rust-compile.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,12 @@ HIRCompileBase::verify_array_capacities (tree ltype, tree rtype,
401401

402402
if (ltype_length != rtype_length)
403403
{
404-
rust_error_at (
405-
rvalue_locus,
406-
"expected an array with a fixed size of " HOST_WIDE_INT_PRINT_UNSIGNED
407-
" elements, found one with " HOST_WIDE_INT_PRINT_UNSIGNED " elements",
408-
ltype_length, rtype_length);
404+
rust_error_at (rvalue_locus, ErrorCode::E0308,
405+
"mismatched types, expected an array with a fixed size "
406+
"of " HOST_WIDE_INT_PRINT_UNSIGNED
407+
" elements, found one with " HOST_WIDE_INT_PRINT_UNSIGNED
408+
" elements",
409+
ltype_length, rtype_length);
409410
return false;
410411
}
411412

gcc/testsuite/rust/compile/arrays2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// { dg-additional-options "-w" }
22
fn main() {
33
let array: [i32; 5] = [1, 2, 3];
4-
// { dg-error "expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 }
4+
// { dg-error "mismatched types, expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 }
55
}

0 commit comments

Comments
 (0)