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