Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E0308] array misamatch types #2525

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

MahadMuhammad
Copy link
Contributor

Array mismatch types - E0308


Code tested:

// { dg-additional-options "-w" }
fn main() {
    let array: [i32; 5] = [1, 2, 3];
    // { dg-error "mismatched types, expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 }
}

Output:

➜  gccrs-build gcc/crab1 /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/arrays2.rs
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/arrays2.rs:3:27: error: mismatched types, expected an array with a fixed size of 5 elements, found one with 3 elements [E0308]
    3 |     let array: [i32; 5] = [1, 2, 3];
      |                           ^

Analyzing compilation unit

Time variable                                   usr           sys          wall           GGC
 phase parsing                      :   0.00 (  0%)   0.00 (  0%)   0.01 (100%)    33k ( 18%)
 parser (global)                    :   0.00 (  0%)   0.00 (  0%)   0.01 (100%)    33k ( 18%)
 TOTAL                              :   0.00          0.00          0.01          179k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

gcc/rust/ChangeLog:

* backend/rust-compile.cc (HIRCompileBase::verify_array_capacities): Added ErrorCode.

gcc/testsuite/ChangeLog:

* rust/compile/arrays2.rs: 

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>
@P-E-P P-E-P added enhancement diagnostic diagnostic static analysis labels Aug 7, 2023
@P-E-P P-E-P added this pull request to the merge queue Aug 9, 2023
Merged via the queue into Rust-GCC:master with commit 67d1f4a Aug 9, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic diagnostic static analysis enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants