1 error[E0308]: if and else have incompatible types
2 --> $DIR/str-array-assignment.rs:13:11
4 LL | let t = if true { s[..2] } else { s };
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found &str
7 = note: expected type `str`
10 error[E0308]: mismatched types
11 --> $DIR/str-array-assignment.rs:15:27
13 LL | let u: &str = if true { s[..2] } else { s };
16 | expected &str, found str
17 | help: consider borrowing here: `&s[..2]`
19 = note: expected type `&str`
22 error[E0277]: the size for values of type `str` cannot be known at compilation time
23 --> $DIR/str-array-assignment.rs:17:7
26 | ^ ------ help: consider borrowing here: `&s[..2]`
28 | doesn't have a size known at compile-time
30 = help: the trait `std::marker::Sized` is not implemented for `str`
31 = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized>
32 = note: all local variables must have a statically known size
34 error[E0308]: mismatched types
35 --> $DIR/str-array-assignment.rs:19:17
37 LL | let w: &str = s[..2];
40 | expected &str, found str
41 | help: consider borrowing here: `&s[..2]`
43 = note: expected type `&str`
46 error: aborting due to 4 previous errors
48 Some errors occurred: E0277, E0308.
49 For more information about an error, try `rustc --explain E0277`.