2020-01-05 00:17:46 +00:00
|
|
|
error[E0308]: `if` and `else` have incompatible types
|
2019-01-06 13:37:03 -08:00
|
|
|
--> $DIR/str-array-assignment.rs:3:37
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let t = if true { s[..2] } else { s };
|
2019-11-15 09:37:01 -08:00
|
|
|
| ------ ^ expected `str`, found `&str`
|
2019-01-06 13:37:03 -08:00
|
|
|
| |
|
|
|
|
| expected because of this
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/str-array-assignment.rs:5:27
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let u: &str = if true { s[..2] } else { s };
|
2018-06-26 11:39:37 -07:00
|
|
|
| ^^^^^^
|
|
|
|
| |
|
2019-11-15 09:37:01 -08:00
|
|
|
| expected `&str`, found `str`
|
2018-06-26 11:39:37 -07:00
|
|
|
| help: consider borrowing here: `&s[..2]`
|
2017-11-24 14:47:40 -08:00
|
|
|
|
2018-07-10 23:10:13 +02:00
|
|
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/str-array-assignment.rs:7:7
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let v = s[..2];
|
2020-07-10 18:11:40 -07:00
|
|
|
| ^ doesn't have a size known at compile-time
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
2020-09-02 10:40:56 +03:00
|
|
|
= help: the trait `Sized` is not implemented for `str`
|
2017-11-24 14:47:40 -08:00
|
|
|
= note: all local variables must have a statically known size
|
2018-05-29 00:11:34 +09:00
|
|
|
= help: unsized locals are gated as an unstable feature
|
2020-07-10 18:11:40 -07:00
|
|
|
help: consider borrowing here
|
|
|
|
|
|
|
|
|
LL | let v = &s[..2];
|
2021-06-21 19:07:19 -07:00
|
|
|
| +
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/str-array-assignment.rs:9:17
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let w: &str = s[..2];
|
2019-11-18 21:00:24 -08:00
|
|
|
| ---- ^^^^^^
|
|
|
|
| | |
|
|
|
|
| | expected `&str`, found `str`
|
|
|
|
| | help: consider borrowing here: `&s[..2]`
|
|
|
|
| expected due to this
|
2017-11-24 14:47:40 -08:00
|
|
|
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
|
2019-04-17 13:26:38 -04:00
|
|
|
Some errors have detailed explanations: E0277, E0308.
|
2018-03-03 15:59:40 +01:00
|
|
|
For more information about an error, try `rustc --explain E0277`.
|