Debian Codegraph @

gcc/testsuite/rust/compile/tuple_mismatch.rs

raw
1 fn main() {
2 let (_,) = 1; // { dg-error "expected <integer>, found tuple" }
3 let (_,) = (1, 2); // { dg-error "expected a tuple with 2 elements, found one with 1 element" }
4 let (_, _) = (1, 2, 3); // { dg-error "expected a tuple with 3 elements, found one with 2 elements" }
5 let (_, _) = (1,); // { dg-error "expected a tuple with 1 element, found one with 2 elements" }
6 }
7
8 // The lhs and rhs sizes don't match, but we still resolve 'a' to be bool, we don't
9 // error out immediately once we notice the size mismatch.
10 fn foo() -> i32 { // { dg-error "mismatched types, expected .i32. but got .bool." }
11 let (a, _) = (true, 2, 3); // { dg-error "expected a tuple with 3 elements, found one with 2 elements" }
12 a
13 }