|
| 1 | +error[E0308]: mismatched types |
| 2 | + --> $DIR/coerce-for-loop-issue-122561.rs:9:5 |
| 3 | + | |
| 4 | +LL | fn atleast_once_iter_range() -> bool { |
| 5 | + | ---- expected `bool` because of return type |
| 6 | +LL | / for i in 0..3 { |
| 7 | +LL | | |
| 8 | +LL | | return false; |
| 9 | +LL | | } |
| 10 | + | |_____^ expected `bool`, found `()` |
| 11 | + |
| 12 | +error[E0308]: mismatched types |
| 13 | + --> $DIR/coerce-for-loop-issue-122561.rs:16:5 |
| 14 | + | |
| 15 | +LL | fn atleast_once_iter_range_neg() -> bool { |
| 16 | + | ---- expected `bool` because of return type |
| 17 | +LL | / for i in -3..-1 { |
| 18 | +LL | | |
| 19 | +LL | | return false; |
| 20 | +LL | | } |
| 21 | + | |_____^ expected `bool`, found `()` |
| 22 | + |
| 23 | +error[E0308]: mismatched types |
| 24 | + --> $DIR/coerce-for-loop-issue-122561.rs:23:5 |
| 25 | + | |
| 26 | +LL | fn atleast_once_iter_range_inclusive() -> bool { |
| 27 | + | ---- expected `bool` because of return type |
| 28 | +LL | / for i in 0..=3 { |
| 29 | +LL | | |
| 30 | +LL | | return false; |
| 31 | +LL | | } |
| 32 | + | |_____^ expected `bool`, found `()` |
| 33 | + |
| 34 | +error[E0308]: mismatched types |
| 35 | + --> $DIR/coerce-for-loop-issue-122561.rs:30:5 |
| 36 | + | |
| 37 | +LL | fn atleast_once_iter_range_inclusive_neg() -> bool { |
| 38 | + | ---- expected `bool` because of return type |
| 39 | +LL | / for i in -3..=-1 { |
| 40 | +LL | | |
| 41 | +LL | | return false; |
| 42 | +LL | | } |
| 43 | + | |_____^ expected `bool`, found `()` |
| 44 | + |
| 45 | +error[E0308]: mismatched types |
| 46 | + --> $DIR/coerce-for-loop-issue-122561.rs:37:5 |
| 47 | + | |
| 48 | +LL | fn atleast_once_iter_infinite_range() -> bool { |
| 49 | + | ---- expected `bool` because of return type |
| 50 | +LL | / for i in 0.. { |
| 51 | +LL | | |
| 52 | +LL | | return false; |
| 53 | +LL | | } |
| 54 | + | |_____^ expected `bool`, found `()` |
| 55 | + |
| 56 | +error[E0308]: mismatched types |
| 57 | + --> $DIR/coerce-for-loop-issue-122561.rs:44:5 |
| 58 | + | |
| 59 | +LL | fn atleast_once_iter_infinite_range_neg() -> bool { |
| 60 | + | ---- expected `bool` because of return type |
| 61 | +LL | / for i in -3.. { |
| 62 | +LL | | |
| 63 | +LL | | return false; |
| 64 | +LL | | } |
| 65 | + | |_____^ expected `bool`, found `()` |
| 66 | + |
| 67 | +error[E0308]: mismatched types |
| 68 | + --> $DIR/coerce-for-loop-issue-122561.rs:51:5 |
| 69 | + | |
| 70 | +LL | fn atleast_once_iter_array() -> bool { |
| 71 | + | ---- expected `bool` because of return type |
| 72 | +LL | / for i in [1, 2, 3] { |
| 73 | +LL | | |
| 74 | +LL | | return false; |
| 75 | +LL | | } |
| 76 | + | |_____^ expected `bool`, found `()` |
| 77 | + |
| 78 | +error[E0308]: mismatched types |
| 79 | + --> $DIR/coerce-for-loop-issue-122561.rs:58:5 |
| 80 | + | |
| 81 | +LL | fn atleast_once_iter_array_ref() -> bool { |
| 82 | + | ---- expected `bool` because of return type |
| 83 | +LL | / for i in &[1, 2, 3] { |
| 84 | +LL | | |
| 85 | +LL | | return false; |
| 86 | +LL | | } |
| 87 | + | |_____^ expected `bool`, found `()` |
| 88 | + |
| 89 | +error[E0308]: mismatched types |
| 90 | + --> $DIR/coerce-for-loop-issue-122561.rs:67:5 |
| 91 | + | |
| 92 | +LL | fn zero_iter_range() -> bool { |
| 93 | + | ---- expected `bool` because of return type |
| 94 | +LL | / for i in 0..0 { |
| 95 | +LL | | |
| 96 | +LL | | return false; |
| 97 | +LL | | } |
| 98 | + | |_____^ expected `bool`, found `()` |
| 99 | + | |
| 100 | +note: the function expects a value to always be returned, but loops might run zero times |
| 101 | + --> $DIR/coerce-for-loop-issue-122561.rs:67:5 |
| 102 | + | |
| 103 | +LL | for i in 0..0 { |
| 104 | + | ^^^^^^^^^^^^^ this might have zero elements to iterate on |
| 105 | +LL | |
| 106 | +LL | return false; |
| 107 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 108 | +help: return a value for the case when the loop has zero elements to iterate on |
| 109 | + | |
| 110 | +LL ~ } |
| 111 | +LL + /* `bool` value */ |
| 112 | + | |
| 113 | +help: otherwise consider changing the return type to account for that possibility |
| 114 | + | |
| 115 | +LL ~ fn zero_iter_range() -> Option<bool> { |
| 116 | +LL | for i in 0..0 { |
| 117 | +LL | |
| 118 | +LL ~ return Some(false); |
| 119 | +LL ~ } |
| 120 | +LL + None |
| 121 | + | |
| 122 | + |
| 123 | +error[E0308]: mismatched types |
| 124 | + --> $DIR/coerce-for-loop-issue-122561.rs:74:5 |
| 125 | + | |
| 126 | +LL | fn zero_iter_array() -> bool { |
| 127 | + | ---- expected `bool` because of return type |
| 128 | +LL | / for i in [] { |
| 129 | +LL | | |
| 130 | +LL | | return false; |
| 131 | +LL | | } |
| 132 | + | |_____^ expected `bool`, found `()` |
| 133 | + | |
| 134 | +note: the function expects a value to always be returned, but loops might run zero times |
| 135 | + --> $DIR/coerce-for-loop-issue-122561.rs:74:5 |
| 136 | + | |
| 137 | +LL | for i in [] { |
| 138 | + | ^^^^^^^^^^^ this might have zero elements to iterate on |
| 139 | +LL | |
| 140 | +LL | return false; |
| 141 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 142 | +help: return a value for the case when the loop has zero elements to iterate on |
| 143 | + | |
| 144 | +LL ~ } |
| 145 | +LL + /* `bool` value */ |
| 146 | + | |
| 147 | +help: otherwise consider changing the return type to account for that possibility |
| 148 | + | |
| 149 | +LL ~ fn zero_iter_array() -> Option<bool> { |
| 150 | +LL | for i in [] { |
| 151 | +LL | |
| 152 | +LL ~ return Some(false); |
| 153 | +LL ~ } |
| 154 | +LL + None |
| 155 | + | |
| 156 | + |
| 157 | +error[E0308]: mismatched types |
| 158 | + --> $DIR/coerce-for-loop-issue-122561.rs:81:5 |
| 159 | + | |
| 160 | +LL | fn zero_iter_array_ref() -> bool { |
| 161 | + | ---- expected `bool` because of return type |
| 162 | +LL | / for i in &[] { |
| 163 | +LL | | |
| 164 | +LL | | return false; |
| 165 | +LL | | } |
| 166 | + | |_____^ expected `bool`, found `()` |
| 167 | + | |
| 168 | +note: the function expects a value to always be returned, but loops might run zero times |
| 169 | + --> $DIR/coerce-for-loop-issue-122561.rs:81:5 |
| 170 | + | |
| 171 | +LL | for i in &[] { |
| 172 | + | ^^^^^^^^^^^^ this might have zero elements to iterate on |
| 173 | +LL | |
| 174 | +LL | return false; |
| 175 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 176 | +help: return a value for the case when the loop has zero elements to iterate on |
| 177 | + | |
| 178 | +LL ~ } |
| 179 | +LL + /* `bool` value */ |
| 180 | + | |
| 181 | +help: otherwise consider changing the return type to account for that possibility |
| 182 | + | |
| 183 | +LL ~ fn zero_iter_array_ref() -> Option<bool> { |
| 184 | +LL | for i in &[] { |
| 185 | +LL | |
| 186 | +LL ~ return Some(false); |
| 187 | +LL ~ } |
| 188 | +LL + None |
| 189 | + | |
| 190 | + |
| 191 | +error[E0308]: mismatched types |
| 192 | + --> $DIR/coerce-for-loop-issue-122561.rs:93:5 |
| 193 | + | |
| 194 | +LL | fn atlast_once_iter_array_var() -> bool { |
| 195 | + | ---- expected `bool` because of return type |
| 196 | +LL | let x = [1, 2, 3]; |
| 197 | +LL | / for i in x { |
| 198 | +LL | | |
| 199 | +LL | | return false; |
| 200 | +LL | | } |
| 201 | + | |_____^ expected `bool`, found `()` |
| 202 | + | |
| 203 | +note: the function expects a value to always be returned, but loops might run zero times |
| 204 | + --> $DIR/coerce-for-loop-issue-122561.rs:93:5 |
| 205 | + | |
| 206 | +LL | for i in x { |
| 207 | + | ^^^^^^^^^^ this might have zero elements to iterate on |
| 208 | +LL | |
| 209 | +LL | return false; |
| 210 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 211 | +help: return a value for the case when the loop has zero elements to iterate on |
| 212 | + | |
| 213 | +LL ~ } |
| 214 | +LL + /* `bool` value */ |
| 215 | + | |
| 216 | +help: otherwise consider changing the return type to account for that possibility |
| 217 | + | |
| 218 | +LL ~ fn atlast_once_iter_array_var() -> Option<bool> { |
| 219 | +LL | let x = [1, 2, 3]; |
| 220 | +LL | for i in x { |
| 221 | +LL | |
| 222 | +LL ~ return Some(false); |
| 223 | +LL ~ } |
| 224 | +LL + None |
| 225 | + | |
| 226 | + |
| 227 | +error[E0308]: mismatched types |
| 228 | + --> $DIR/coerce-for-loop-issue-122561.rs:100:5 |
| 229 | + | |
| 230 | +LL | fn atleast_once_iter_vec() -> bool { |
| 231 | + | ---- expected `bool` because of return type |
| 232 | +LL | / for i in vec![1, 2, 3] { |
| 233 | +LL | | |
| 234 | +LL | | return false; |
| 235 | +LL | | } |
| 236 | + | |_____^ expected `bool`, found `()` |
| 237 | + | |
| 238 | +note: the function expects a value to always be returned, but loops might run zero times |
| 239 | + --> $DIR/coerce-for-loop-issue-122561.rs:100:5 |
| 240 | + | |
| 241 | +LL | | } |
| 242 | + | |_________^ this might have zero elements to iterate on |
| 243 | +... |
| 244 | +LL | / for i in vec![1, 2, 3] { |
| 245 | +LL | |
| 246 | +LL | return false; |
| 247 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 248 | +help: return a value for the case when the loop has zero elements to iterate on |
| 249 | + | |
| 250 | +LL ~ } |
| 251 | +LL + /* `bool` value */ |
| 252 | + | |
| 253 | +help: otherwise consider changing the return type to account for that possibility |
| 254 | + | |
| 255 | +LL ~ fn atleast_once_iter_vec() -> Option<bool> { |
| 256 | +LL | for i in vec![1, 2, 3] { |
| 257 | +LL | |
| 258 | +LL ~ return Some(false); |
| 259 | +LL ~ } |
| 260 | +LL + None |
| 261 | + | |
| 262 | + |
| 263 | +error[E0308]: mismatched types |
| 264 | + --> $DIR/coerce-for-loop-issue-122561.rs:107:5 |
| 265 | + | |
| 266 | +LL | fn atleast_once_iter_array_iter() -> bool { |
| 267 | + | ---- expected `bool` because of return type |
| 268 | +LL | / for i in [1, 2, 3].iter() { |
| 269 | +LL | | |
| 270 | +LL | | return false; |
| 271 | +LL | | } |
| 272 | + | |_____^ expected `bool`, found `()` |
| 273 | + | |
| 274 | +note: the function expects a value to always be returned, but loops might run zero times |
| 275 | + --> $DIR/coerce-for-loop-issue-122561.rs:107:5 |
| 276 | + | |
| 277 | +LL | for i in [1, 2, 3].iter() { |
| 278 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^ this might have zero elements to iterate on |
| 279 | +LL | |
| 280 | +LL | return false; |
| 281 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 282 | +help: return a value for the case when the loop has zero elements to iterate on |
| 283 | + | |
| 284 | +LL ~ } |
| 285 | +LL + /* `bool` value */ |
| 286 | + | |
| 287 | +help: otherwise consider changing the return type to account for that possibility |
| 288 | + | |
| 289 | +LL ~ fn atleast_once_iter_array_iter() -> Option<bool> { |
| 290 | +LL | for i in [1, 2, 3].iter() { |
| 291 | +LL | |
| 292 | +LL ~ return Some(false); |
| 293 | +LL ~ } |
| 294 | +LL + None |
| 295 | + | |
| 296 | + |
| 297 | +error[E0308]: mismatched types |
| 298 | + --> $DIR/coerce-for-loop-issue-122561.rs:114:5 |
| 299 | + | |
| 300 | +LL | fn atleast_once_iter_func_result() -> bool { |
| 301 | + | ---- expected `bool` because of return type |
| 302 | +LL | / for i in get_iter() { |
| 303 | +LL | | |
| 304 | +LL | | return false; |
| 305 | +LL | | } |
| 306 | + | |_____^ expected `bool`, found `()` |
| 307 | + | |
| 308 | +note: the function expects a value to always be returned, but loops might run zero times |
| 309 | + --> $DIR/coerce-for-loop-issue-122561.rs:114:5 |
| 310 | + | |
| 311 | +LL | for i in get_iter() { |
| 312 | + | ^^^^^^^^^^^^^^^^^^^ this might have zero elements to iterate on |
| 313 | +LL | |
| 314 | +LL | return false; |
| 315 | + | ------------ if the loop doesn't execute, this value would never get returned |
| 316 | +help: return a value for the case when the loop has zero elements to iterate on |
| 317 | + | |
| 318 | +LL ~ } |
| 319 | +LL + /* `bool` value */ |
| 320 | + | |
| 321 | +help: otherwise consider changing the return type to account for that possibility |
| 322 | + | |
| 323 | +LL ~ fn atleast_once_iter_func_result() -> Option<bool> { |
| 324 | +LL | for i in get_iter() { |
| 325 | +LL | |
| 326 | +LL ~ return Some(false); |
| 327 | +LL ~ } |
| 328 | +LL + None |
| 329 | + | |
| 330 | + |
| 331 | +error: aborting due to 15 previous errors |
| 332 | + |
| 333 | +For more information about this error, try `rustc --explain E0308`. |
0 commit comments