]> git.lizzy.rs Git - rust.git/blob - src/test/ui/did_you_mean/compatible-variants.rs
Test `expect` with `forbid` and fix doc errors (RFC-2383)
[rust.git] / src / test / ui / did_you_mean / compatible-variants.rs
1 enum Hey<A, B> {
2     A(A),
3     B(B),
4 }
5
6 struct Foo {
7     bar: Option<i32>,
8 }
9
10 fn f() {}
11
12 fn a() -> Option<()> {
13     while false {
14         //~^ ERROR mismatched types
15         f();
16     }
17     //~^ HELP try adding an expression
18 }
19
20 fn b() -> Result<(), ()> {
21     f()
22     //~^ ERROR mismatched types
23     //~| HELP try adding an expression
24 }
25
26 fn main() {
27     let _: Option<()> = while false {};
28     //~^ ERROR mismatched types
29     //~| HELP try wrapping
30     let _: Option<()> = {
31         while false {}
32         //~^ ERROR mismatched types
33         //~| HELP try adding an expression
34     };
35     let _: Result<i32, i32> = 1;
36     //~^ ERROR mismatched types
37     //~| HELP try wrapping
38     let _: Option<i32> = 1;
39     //~^ ERROR mismatched types
40     //~| HELP try wrapping
41     let _: Hey<i32, i32> = 1;
42     //~^ ERROR mismatched types
43     //~| HELP try wrapping
44     let _: Hey<i32, bool> = false;
45     //~^ ERROR mismatched types
46     //~| HELP try wrapping
47     let bar = 1i32;
48     let _ = Foo { bar };
49     //~^ ERROR mismatched types
50     //~| HELP try wrapping
51 }