]> git.lizzy.rs Git - rust.git/blob - src/test/ui/str/str-array-assignment.stderr
Auto merge of #60063 - spastorino:place2_2, r=oli-obk
[rust.git] / src / test / ui / str / str-array-assignment.stderr
1 error[E0308]: if and else have incompatible types
2   --> $DIR/str-array-assignment.rs:3:37
3    |
4 LL |   let t = if true { s[..2] } else { s };
5    |                     ------          ^ expected str, found &str
6    |                     |
7    |                     expected because of this
8    |
9    = note: expected type `str`
10               found type `&str`
11
12 error[E0308]: mismatched types
13   --> $DIR/str-array-assignment.rs:5:27
14    |
15 LL |   let u: &str = if true { s[..2] } else { s };
16    |                           ^^^^^^
17    |                           |
18    |                           expected &str, found str
19    |                           help: consider borrowing here: `&s[..2]`
20    |
21    = note: expected type `&str`
22               found type `str`
23
24 error[E0277]: the size for values of type `str` cannot be known at compilation time
25   --> $DIR/str-array-assignment.rs:7:7
26    |
27 LL |   let v = s[..2];
28    |       ^   ------ help: consider borrowing here: `&s[..2]`
29    |       |
30    |       doesn't have a size known at compile-time
31    |
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
36
37 error[E0308]: mismatched types
38   --> $DIR/str-array-assignment.rs:9:17
39    |
40 LL |   let w: &str = s[..2];
41    |                 ^^^^^^
42    |                 |
43    |                 expected &str, found str
44    |                 help: consider borrowing here: `&s[..2]`
45    |
46    = note: expected type `&str`
47               found type `str`
48
49 error: aborting due to 4 previous errors
50
51 Some errors have detailed explanations: E0277, E0308.
52 For more information about an error, try `rustc --explain E0277`.