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