fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

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