1 error[E0308]: if and else have incompatible types
2 --> $DIR/str-array-assignment.rs:3:37
4 LL | let t = if true { s[..2] } else { s };
5 | ------ ^ expected str, found &str
7 | expected because of this
9 = note: expected type `str`
12 error[E0308]: mismatched types
13 --> $DIR/str-array-assignment.rs:5:27
15 LL | let u: &str = if true { s[..2] } else { s };
18 | expected &str, found str
19 | help: consider borrowing here: `&s[..2]`
21 = note: expected type `&str`
24 error[E0277]: the size for values of type `str` cannot be known at compilation time
25 --> $DIR/str-array-assignment.rs:7:7
28 | ^ ------ help: consider borrowing here: `&s[..2]`
30 | doesn't have a size known at compile-time
32 = help: the trait `std::marker::Sized` is not implemented for `str`
33 = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
34 = note: all local variables must have a statically known size
35 = help: unsized locals are gated as an unstable feature
37 error[E0308]: mismatched types
38 --> $DIR/str-array-assignment.rs:9:17
40 LL | let w: &str = s[..2];
43 | expected &str, found str
44 | help: consider borrowing here: `&s[..2]`
46 = note: expected type `&str`
49 error: aborting due to 4 previous errors
51 Some errors have detailed explanations: E0277, E0308.
52 For more information about an error, try `rustc --explain E0277`.