rust/tests/ui/str/str-array-assignment.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-01-05 00:17:46 +00:00
error[E0308]: `if` and `else` have incompatible types
--> $DIR/str-array-assignment.rs:3:37
|
2018-02-23 00:42:32 +00:00
LL | let t = if true { s[..2] } else { s };
| ------ ^ expected `str`, found `&str`
| |
| expected because of this
error[E0308]: mismatched types
2018-12-25 15:56:47 +00:00
--> $DIR/str-array-assignment.rs:5:27
|
2018-02-23 00:42:32 +00:00
LL | let u: &str = if true { s[..2] } else { s };
2023-04-18 19:44:27 +00:00
| ^^^^^^ expected `&str`, found `str`
|
help: consider borrowing here
|
LL | let u: &str = if true { &s[..2] } else { s };
| +
2018-07-10 21:10:13 +00:00
error[E0277]: the size for values of type `str` cannot be known at compilation time
2018-12-25 15:56:47 +00:00
--> $DIR/str-array-assignment.rs:7:7
|
2018-02-23 00:42:32 +00:00
LL | let v = s[..2];
| ^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: all local variables must have a statically known size
2018-05-28 15:11:34 +00:00
= help: unsized locals are gated as an unstable feature
help: consider borrowing here
|
LL | let v = &s[..2];
| +
error[E0308]: mismatched types
2018-12-25 15:56:47 +00:00
--> $DIR/str-array-assignment.rs:9:17
|
2018-02-23 00:42:32 +00:00
LL | let w: &str = s[..2];
2023-04-18 19:44:27 +00:00
| ---- ^^^^^^ expected `&str`, found `str`
| |
| expected due to this
2023-04-18 19:44:27 +00:00
|
help: consider borrowing here
|
LL | let w: &str = &s[..2];
| +
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0308.
2018-03-03 14:59:40 +00:00
For more information about an error, try `rustc --explain E0277`.