]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/return-bindings.stderr
Rollup merge of #99079 - compiler-errors:issue-99073, r=oli-obk
[rust.git] / src / test / ui / suggestions / return-bindings.stderr
1 error[E0308]: mismatched types
2   --> $DIR/return-bindings.rs:3:17
3    |
4 LL | fn a(i: i32) -> i32 {}
5    |    -            ^^^ expected `i32`, found `()`
6    |    |
7    |    implicitly returns `()` as its body has no tail or `return` expression
8    |
9 help: consider returning the local binding `i`
10    |
11 LL | fn a(i: i32) -> i32 { i }
12    |                       +
13
14 error[E0308]: mismatched types
15   --> $DIR/return-bindings.rs:7:46
16    |
17 LL |       let s: String = if let Some(s) = opt_str {
18    |  ______________________________________________^
19 LL | |
20 LL | |     } else {
21    | |_____^ expected struct `String`, found `()`
22    |
23 help: consider returning the local binding `s`
24    |
25 LL ~     let s: String = if let Some(s) = opt_str {
26 LL +         s
27 LL ~
28    |
29
30 error[E0308]: mismatched types
31   --> $DIR/return-bindings.rs:14:11
32    |
33 LL | fn c() -> Option<i32> {
34    |    -      ^^^^^^^^^^^ expected enum `Option`, found `()`
35    |    |
36    |    implicitly returns `()` as its body has no tail or `return` expression
37    |
38    = note:   expected enum `Option<i32>`
39            found unit type `()`
40 help: consider returning the local binding `x`
41    |
42 LL ~     let x = Some(1);
43 LL +     x
44    |
45
46 error[E0308]: mismatched types
47   --> $DIR/return-bindings.rs:20:46
48    |
49 LL |       let s: String = if let Some(s) = opt_str {
50    |  ______________________________________________^
51 LL | |
52 LL | |     } else {
53    | |_____^ expected struct `String`, found `()`
54    |
55 help: consider returning the local binding `s`
56    |
57 LL ~     let s: String = if let Some(s) = opt_str {
58 LL +         s
59 LL ~
60    |
61
62 error[E0308]: `if` and `else` have incompatible types
63   --> $DIR/return-bindings.rs:30:9
64    |
65 LL |       let s = if let Some(s) = opt_str {
66    |  ______________________________________-
67 LL | |     } else {
68    | |_____- expected because of this
69 LL |           String::new()
70    |           ^^^^^^^^^^^^^ expected `()`, found struct `String`
71    |
72 help: consider returning the local binding `s`
73    |
74 LL ~     let s = if let Some(s) = opt_str {
75 LL +         s
76 LL ~     } else {
77    |
78
79 error[E0308]: mismatched types
80   --> $DIR/return-bindings.rs:37:20
81    |
82 LL |         Some(s) => {}
83    |                    ^^ expected struct `String`, found `()`
84    |
85 help: consider returning the local binding `s`
86    |
87 LL |         Some(s) => { s }
88    |                      +
89
90 error[E0308]: `match` arms have incompatible types
91   --> $DIR/return-bindings.rs:46:17
92    |
93 LL |       let s = match opt_str {
94    |  _____________-
95 LL | |         Some(s) => {}
96    | |                    -- this is found to be of type `()`
97 LL | |         None => String::new(),
98    | |                 ^^^^^^^^^^^^^ expected `()`, found struct `String`
99 LL | |
100 LL | |     };
101    | |_____- `match` arms have incompatible types
102    |
103 help: consider returning the local binding `s`
104    |
105 LL |         Some(s) => { s }
106    |                      +
107
108 error: aborting due to 7 previous errors
109
110 For more information about this error, try `rustc --explain E0308`.