Skip to content

Commit

Permalink
gccrs: [E0308] array misamatch types
Browse files Browse the repository at this point in the history
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 <mahadtxt@gmail.com>
  • Loading branch information
MahadMuhammad authored and P-E-P committed Aug 9, 2023
1 parent a584856 commit 67d1f4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions gcc/rust/backend/rust-compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,12 @@ HIRCompileBase::verify_array_capacities (tree ltype, tree rtype,

if (ltype_length != rtype_length)
{
rust_error_at (
rvalue_locus,
"expected an array with a fixed size of " HOST_WIDE_INT_PRINT_UNSIGNED
" elements, found one with " HOST_WIDE_INT_PRINT_UNSIGNED " elements",
ltype_length, rtype_length);
rust_error_at (rvalue_locus, ErrorCode::E0308,
"mismatched types, expected an array with a fixed size "
"of " HOST_WIDE_INT_PRINT_UNSIGNED
" elements, found one with " HOST_WIDE_INT_PRINT_UNSIGNED
" elements",
ltype_length, rtype_length);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/arrays2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// { dg-additional-options "-w" }
fn main() {
let array: [i32; 5] = [1, 2, 3];
// { dg-error "expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 }
// { dg-error "mismatched types, expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 }
}

0 comments on commit 67d1f4a

Please sign in to comment.