I found an unusual error message when tried to compile the following code -
fn test_error_msg() -> (
Vec<u32>,
Vec<u32>,
HashSet<&'static HttpReq>,
Vec<ConnectionCount>,
Vec<ConnectionCount>,
) {
let mut qps:Vec<Vec<u32>> = Vec::with_capacity(10);
let mut conn_count:Vec<Vec<u32>> = Vec::with_capacity(10);
let mut req_to_secondaries: HashSet<&HttpReq> = HashSet::new();
(qps, req_to_secondaries, conn_count)
}
One of the error messages is
error[E0308]: mismatched types
--> src/main.rs:20:5
|
10 | fn test_error_msg() -> (
| ________________________-
11 | | Vec<u32>,
12 | | Vec<u32>,
13 | | HashSet<&'static HttpReq>,
14 | | Vec<ConnectionCount>,
15 | | Vec<ConnectionCount>,
16 | | ) {
| |_- expected `(Vec<u32>, Vec<u32>, HashSet<&'static HttpReq>, Vec<ConnectionCount>, Vec<ConnectionCount>)` because of return type
...
20 | (qps, req_to_secondaries, conn_count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected a tuple with 5 elements, found one with 3 elements
|
= note: expected tuple `(Vec<u32>, Vec<u32>, HashSet<&'static HttpReq>, Vec<ConnectionCount>, Vec<ConnectionCount>)`
found tuple `(Vec<u32>, Vec<u32>, HashSet<&'static HttpReq>)`
In the note it says found tuple `(Vec<u32>, Vec<u32>, HashSet<&'static HttpReq>)`
but what I'm actually returning is (Vec<Vec<u32>>, Vec<Vec<u32>>, HashSet<&'static HttpReq>)
Is it a bug or there's a reason behind it?
Playground