You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#52605 - estebank:str-plus-eq, r=oli-obk
Do not suggest using `to_owned()` on `&str += &str`
- Don't provide incorrect suggestion for `&str += &str` (fixrust-lang#52410)
- On `&str + String` suggest `&str.to_owned() + &String` as a single suggestion
Copy file name to clipboardexpand all lines: src/test/ui/issue-10401.stderr
-5
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,6 @@ LL | a += { "b" };
5
5
| -^^^^^^^^^^^
6
6
| |
7
7
| cannot use `+=` on type `&str`
8
-
| `+` can't be used to concatenate two `&str` strings
9
-
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
Copy file name to clipboardexpand all lines: src/test/ui/span/issue-39018.stderr
+2-6
Original file line number
Diff line number
Diff line change
@@ -23,12 +23,8 @@ LL | let x = "Hello " + "World!".to_owned();
23
23
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate a `&str` with a `String`
24
24
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
25
25
|
26
-
LL | let x = "Hello ".to_owned() + "World!".to_owned();
27
-
| ^^^^^^^^^^^^^^^^^^^
28
-
help: you also need to borrow the `String` on the right to get a `&str`
29
-
|
30
-
LL | let x = "Hello " + &"World!".to_owned();
31
-
| ^^^^^^^^^^^^^^^^^^^^
26
+
LL | let x = "Hello ".to_owned() + &"World!".to_owned();
0 commit comments