]> git.lizzy.rs Git - rust.git/blob - src/test/ui/did_you_mean/compatible-variants.stderr
Test `expect` with `forbid` and fix doc errors (RFC-2383)
[rust.git] / src / test / ui / did_you_mean / compatible-variants.stderr
1 error[E0308]: mismatched types
2   --> $DIR/compatible-variants.rs:13:5
3    |
4 LL |   fn a() -> Option<()> {
5    |             ---------- expected `Option<()>` because of return type
6 LL | /     while false {
7 LL | |
8 LL | |         f();
9 LL | |     }
10    | |_____^ expected enum `Option`, found `()`
11    |
12    = note:   expected enum `Option<()>`
13            found unit type `()`
14 help: try adding an expression at the end of the block
15    |
16 LL ~     }
17 LL +     None
18    |
19 LL ~     }
20 LL +     Some(())
21    |
22
23 error[E0308]: mismatched types
24   --> $DIR/compatible-variants.rs:21:5
25    |
26 LL | fn b() -> Result<(), ()> {
27    |           -------------- expected `Result<(), ()>` because of return type
28 LL |     f()
29    |     ^^^ expected enum `Result`, found `()`
30    |
31    = note:   expected enum `Result<(), ()>`
32            found unit type `()`
33 help: try adding an expression at the end of the block
34    |
35 LL ~     f();
36 LL +     Ok(())
37    |
38
39 error[E0308]: mismatched types
40   --> $DIR/compatible-variants.rs:27:25
41    |
42 LL |     let _: Option<()> = while false {};
43    |            ----------   ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
44    |            |
45    |            expected due to this
46    |
47    = note:   expected enum `Option<()>`
48            found unit type `()`
49 help: try wrapping the expression in `Some`
50    |
51 LL |     let _: Option<()> = Some(while false {});
52    |                         +++++              +
53
54 error[E0308]: mismatched types
55   --> $DIR/compatible-variants.rs:31:9
56    |
57 LL |         while false {}
58    |         ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
59    |
60    = note:   expected enum `Option<()>`
61            found unit type `()`
62 help: try adding an expression at the end of the block
63    |
64 LL ~         while false {}
65 LL +         None
66    |
67 LL ~         while false {}
68 LL +         Some(())
69    |
70
71 error[E0308]: mismatched types
72   --> $DIR/compatible-variants.rs:35:31
73    |
74 LL |     let _: Result<i32, i32> = 1;
75    |            ----------------   ^ expected enum `Result`, found integer
76    |            |
77    |            expected due to this
78    |
79    = note: expected enum `Result<i32, i32>`
80               found type `{integer}`
81 help: try wrapping the expression in a variant of `Result`
82    |
83 LL |     let _: Result<i32, i32> = Ok(1);
84    |                               +++ +
85 LL |     let _: Result<i32, i32> = Err(1);
86    |                               ++++ +
87
88 error[E0308]: mismatched types
89   --> $DIR/compatible-variants.rs:38:26
90    |
91 LL |     let _: Option<i32> = 1;
92    |            -----------   ^ expected enum `Option`, found integer
93    |            |
94    |            expected due to this
95    |
96    = note: expected enum `Option<i32>`
97               found type `{integer}`
98 help: try wrapping the expression in `Some`
99    |
100 LL |     let _: Option<i32> = Some(1);
101    |                          +++++ +
102
103 error[E0308]: mismatched types
104   --> $DIR/compatible-variants.rs:41:28
105    |
106 LL |     let _: Hey<i32, i32> = 1;
107    |            -------------   ^ expected enum `Hey`, found integer
108    |            |
109    |            expected due to this
110    |
111    = note: expected enum `Hey<i32, i32>`
112               found type `{integer}`
113 help: try wrapping the expression in a variant of `Hey`
114    |
115 LL |     let _: Hey<i32, i32> = Hey::A(1);
116    |                            +++++++ +
117 LL |     let _: Hey<i32, i32> = Hey::B(1);
118    |                            +++++++ +
119
120 error[E0308]: mismatched types
121   --> $DIR/compatible-variants.rs:44:29
122    |
123 LL |     let _: Hey<i32, bool> = false;
124    |            --------------   ^^^^^ expected enum `Hey`, found `bool`
125    |            |
126    |            expected due to this
127    |
128    = note: expected enum `Hey<i32, bool>`
129               found type `bool`
130 help: try wrapping the expression in `Hey::B`
131    |
132 LL |     let _: Hey<i32, bool> = Hey::B(false);
133    |                             +++++++     +
134
135 error[E0308]: mismatched types
136   --> $DIR/compatible-variants.rs:48:19
137    |
138 LL |     let _ = Foo { bar };
139    |                   ^^^ expected enum `Option`, found `i32`
140    |
141    = note: expected enum `Option<i32>`
142               found type `i32`
143 help: try wrapping the expression in `Some`
144    |
145 LL |     let _ = Foo { bar: Some(bar) };
146    |                   ++++++++++   +
147
148 error: aborting due to 9 previous errors
149
150 For more information about this error, try `rustc --explain E0308`.