rust/src/test/ui/span/issue-39018.stderr

36 lines
1.7 KiB
Plaintext
Raw Normal View History

error[E0369]: binary operation `+` cannot be applied to type `&str`
--> $DIR/issue-39018.rs:12:13
|
2018-02-22 18:42:32 -06:00
LL | let x = "Hello " + "World!";
2017-03-28 06:06:01 -05:00
| ^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
2017-05-16 08:12:24 -05:00
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
2017-06-28 01:16:04 -05:00
|
2018-02-24 17:01:39 -06:00
LL | let x = "Hello ".to_owned() + "World!";
2017-06-28 01:16:04 -05:00
| ^^^^^^^^^^^^^^^^^^^
error[E0369]: binary operation `+` cannot be applied to type `World`
2017-11-20 06:13:27 -06:00
--> $DIR/issue-39018.rs:18:13
|
2018-02-22 18:42:32 -06:00
LL | let y = World::Hello + World::Goodbye;
2017-03-28 06:06:01 -05:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: an implementation of `std::ops::Add` might be missing for `World`
error[E0369]: binary operation `+` cannot be applied to type `&str`
--> $DIR/issue-39018.rs:21:13
|
21 | let x = "Hello " + "World!".to_owned();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate a `&str` with a `String`
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
21 | let x = "Hello ".to_owned() + "World!".to_owned();
| ^^^^^^^^^^^^^^^^^^^
help: you also need to borrow the `String` on the right to get a `&str`
|
21 | let x = "Hello " + &"World!".to_owned();
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
2018-02-19 14:40:25 -06:00
If you want more information on this error, try using "rustc --explain E0369"