summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/option_if_let_else.stderr
blob: daba606004e114d68ed95d95682e94a4fd59c7f2 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:12:5
   |
LL | /     if let Some(x) = string {
LL | |         (true, x)
LL | |     } else {
LL | |         (false, "hello")
LL | |     }
   | |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))`
   |
   = note: `-D clippy::option-if-let-else` implied by `-D warnings`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:30:13
   |
LL |     let _ = if let Some(s) = *string { s.len() } else { 0 };
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:31:13
   |
LL |     let _ = if let Some(s) = &num { s } else { &0 };
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:32:13
   |
LL |       let _ = if let Some(s) = &mut num {
   |  _____________^
LL | |         *s += 1;
LL | |         s
LL | |     } else {
LL | |         &mut 0
LL | |     };
   | |_____^
   |
help: try
   |
LL ~     let _ = num.as_mut().map_or(&mut 0, |s| {
LL +         *s += 1;
LL +         s
LL ~     });
   |

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:38:13
   |
LL |     let _ = if let Some(ref s) = num { s } else { &0 };
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:39:13
   |
LL |       let _ = if let Some(mut s) = num {
   |  _____________^
LL | |         s += 1;
LL | |         s
LL | |     } else {
LL | |         0
LL | |     };
   | |_____^
   |
help: try
   |
LL ~     let _ = num.map_or(0, |mut s| {
LL +         s += 1;
LL +         s
LL ~     });
   |

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:45:13
   |
LL |       let _ = if let Some(ref mut s) = num {
   |  _____________^
LL | |         *s += 1;
LL | |         s
LL | |     } else {
LL | |         &mut 0
LL | |     };
   | |_____^
   |
help: try
   |
LL ~     let _ = num.as_mut().map_or(&mut 0, |s| {
LL +         *s += 1;
LL +         s
LL ~     });
   |

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:54:5
   |
LL | /     if let Some(x) = arg {
LL | |         let y = x * x;
LL | |         y * y
LL | |     } else {
LL | |         13
LL | |     }
   | |_____^
   |
help: try
   |
LL ~     arg.map_or(13, |x| {
LL +         let y = x * x;
LL +         y * y
LL +     })
   |

error: use Option::map_or_else instead of an if let/else
  --> $DIR/option_if_let_else.rs:67:13
   |
LL |       let _ = if let Some(x) = arg {
   |  _____________^
LL | |         x
LL | |     } else {
LL | |         // map_or_else must be suggested
LL | |         side_effect()
LL | |     };
   | |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)`

error: use Option::map_or_else instead of an if let/else
  --> $DIR/option_if_let_else.rs:76:13
   |
LL |       let _ = if let Some(x) = arg {
   |  _____________^
LL | |         x * x * x * x
LL | |     } else {
LL | |         let mut y = 1;
...  |
LL | |         y
LL | |     };
   | |_____^
   |
help: try
   |
LL ~     let _ = arg.map_or_else(|| {
LL +         let mut y = 1;
LL +         y = (y + 2 / y) / 2;
LL +         y = (y + 2 / y) / 2;
LL +         y
LL ~     }, |x| x * x * x * x);
   |

error: use Option::map_or_else instead of an if let/else
  --> $DIR/option_if_let_else.rs:109:13
   |
LL | /             if let Some(idx) = s.find('.') {
LL | |                 vec![s[..idx].to_string(), s[idx..].to_string()]
LL | |             } else {
LL | |                 vec![s.to_string()]
LL | |             }
   | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:133:13
   |
LL |     let _ = if let Some(x) = optional { x + 2 } else { 5 };
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:142:13
   |
LL |       let _ = if let Some(x) = Some(0) {
   |  _____________^
LL | |         loop {
LL | |             if x == 0 {
LL | |                 break x;
...  |
LL | |         0
LL | |     };
   | |_____^
   |
help: try
   |
LL ~     let _ = Some(0).map_or(0, |x| loop {
LL +             if x == 0 {
LL +                 break x;
LL +             }
LL ~         });
   |

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:170:13
   |
LL |     let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`

error: use Option::map_or instead of an if let/else
  --> $DIR/option_if_let_else.rs:174:13
   |
LL |       let _ = if let Some(x) = Some(0) {
   |  _____________^
LL | |         let s = s;
LL | |         s.len() + x
LL | |     } else {
LL | |         1
LL | |     };
   | |_____^
   |
help: try
   |
LL ~     let _ = Some(0).map_or(1, |x| {
LL +         let s = s;
LL +         s.len() + x
LL ~     });
   |

error: aborting due to 15 previous errors