2 // Check that coercions can unify if-else, match arms and array elements.
4 // Try to construct if-else chains, matches and arrays out of given expressions.
6 ($last:expr $(, $rest:expr)+) => {
7 // Last expression comes first because of whacky ifs and matches.
8 let _ = $(if false { $rest })else+ else { $last };
10 let _ = match 0 { $(_ if false => $rest,)+ _ => $last };
12 let _ = [$($rest,)+ $last];
16 // Check all non-uniform cases of 2 and 3 expressions of 2 types.
18 ($a:expr, $b:expr) => {
32 // Check all non-uniform cases of 2 and 3 expressions of 3 types.
34 ($a:expr, $b:expr, $c:expr) => {
35 // Delegate to check2 for cases where a type repeats.
40 // Check the remaining cases, i.e., permutations of ($a, $b, $c).
50 use std::mem::size_of;
56 check3!(foo, bar, foo as fn());
57 check3!(size_of::<u8>, size_of::<u16>, size_of::<usize> as fn() -> usize);
59 let s = String::from("bar");
63 let v = vec![1, 2, 3];
66 // Make sure in-array coercion still works.
67 let _ = [("a", Default::default()), (Default::default(), "b"), (&s, &s)];