1 #![feature(never_type)]
3 fn foo(x: usize, y: !, z: usize) { }
7 //~^ ERROR mismatched types
11 // Divergence happens in the argument itself, definitely ok.
16 // This test fails because the divergence happens **after** the
18 foo(22, 44, return); //~ ERROR mismatched types
22 // This test passes because `a` has type `!`:
26 foo(a, b, c); // ... and hence a reference to `a` is expected to diverge.
27 //~^ ERROR mismatched types
31 // This test probably could pass but we don't *know* that `a`
32 // has type `!` so we don't let it work.
36 foo(a, b, c); //~ ERROR mismatched types
40 // This fn fails because `a` has type `usize`, and hence a
41 // reference to is it **not** considered to diverge.
42 let a: usize = return;
45 foo(a, b, c); //~ ERROR mismatched types
49 // Return is coerced to `!` just fine, but `22` cannot be.
50 let x: [!; 2] = [return, 22]; //~ ERROR mismatched types
54 // Error: divergence has not yet occurred.
55 let x: [!; 2] = [22, return]; //~ ERROR mismatched types
59 // No divergence at all.
60 let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types
64 // Divergence happens before coercion: OK
65 let x: (usize, !, usize) = (return, 44, 66);
66 //~^ ERROR mismatched types
70 // Divergence happens before coercion: OK
71 let x: (usize, !, usize) = (22, return, 66);
75 // Error: divergence happens too late
76 let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types