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