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
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Improve suggestions for type errors with string concatenation
Now, multipart suggestions are used instead of `span_to_snippet`, which
improves code quality, makes the suggestion work even without access to
source code, and, most importantly, improves the rendering of the
suggestion.
Copy file name to clipboardExpand all lines: src/test/ui/issues/issue-47377.stderr
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ LL | let _a = b + ", World!";
10
10
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/issues/issue-47380.stderr
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ LL | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!";
10
10
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
11
11
|
12
12
LL | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!";
Copy file name to clipboardExpand all lines: src/test/ui/span/issue-39018.stderr
+14-12Lines changed: 14 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ LL | let x = "Hello " + "World!";
10
10
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
11
11
|
12
12
LL | let x = "Hello ".to_owned() + "World!";
13
-
| ~~~~~~~~~~~~~~~~~~~
13
+
| +++++++++++
14
14
15
15
error[E0369]: cannot add `World` to `World`
16
16
--> $DIR/issue-39018.rs:8:26
@@ -49,7 +49,7 @@ LL | let x = "Hello " + "World!".to_owned();
49
49
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
50
50
|
51
51
LL | let x = "Hello ".to_owned() + &"World!".to_owned();
52
-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
+
| +++++++++++ +
53
53
54
54
error[E0369]: cannot add `&String` to `&String`
55
55
--> $DIR/issue-39018.rs:26:16
@@ -62,8 +62,9 @@ LL | let _ = &a + &b;
62
62
|
63
63
help: 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
64
64
|
65
-
LL | let _ = a + &b;
66
-
| ~
65
+
LL - let _ = &a + &b;
66
+
LL + let _ = a + &b;
67
+
|
67
68
68
69
error[E0369]: cannot add `String` to `&String`
69
70
--> $DIR/issue-39018.rs:27:16
@@ -76,8 +77,9 @@ LL | let _ = &a + b;
76
77
|
77
78
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
78
79
|
79
-
LL | let _ = a + &b;
80
-
| ~ ~~
80
+
LL - let _ = &a + b;
81
+
LL + let _ = a + &b;
82
+
|
81
83
82
84
error[E0308]: mismatched types
83
85
--> $DIR/issue-39018.rs:29:17
@@ -100,7 +102,7 @@ LL | let _ = e + b;
100
102
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
101
103
|
102
104
LL | let _ = e.to_owned() + &b;
103
-
| ~~~~~~~~~~~~ ~~
105
+
| +++++++++++ +
104
106
105
107
error[E0369]: cannot add `&String` to `&String`
106
108
--> $DIR/issue-39018.rs:31:15
@@ -114,7 +116,7 @@ LL | let _ = e + &b;
114
116
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
115
117
|
116
118
LL | let _ = e.to_owned() + &b;
117
-
| ~~~~~~~~~~~~
119
+
| +++++++++++
118
120
119
121
error[E0369]: cannot add `&str` to `&String`
120
122
--> $DIR/issue-39018.rs:32:15
@@ -128,7 +130,7 @@ LL | let _ = e + d;
128
130
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
129
131
|
130
132
LL | let _ = e.to_owned() + d;
131
-
| ~~~~~~~~~~~~
133
+
| +++++++++++
132
134
133
135
error[E0369]: cannot add `&&str` to `&String`
134
136
--> $DIR/issue-39018.rs:33:15
@@ -142,7 +144,7 @@ LL | let _ = e + &d;
142
144
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
143
145
|
144
146
LL | let _ = e.to_owned() + &d;
145
-
| ~~~~~~~~~~~~
147
+
| +++++++++++
146
148
147
149
error[E0369]: cannot add `&&str` to `&&str`
148
150
--> $DIR/issue-39018.rs:34:16
@@ -172,7 +174,7 @@ LL | let _ = c + &d;
172
174
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
173
175
|
174
176
LL | let _ = c.to_owned() + &d;
175
-
| ~~~~~~~~~~~~
177
+
| +++++++++++
176
178
177
179
error[E0369]: cannot add `&str` to `&str`
178
180
--> $DIR/issue-39018.rs:37:15
@@ -186,7 +188,7 @@ LL | let _ = c + d;
186
188
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/str/str-concat-on-double-ref.stderr
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ LL | let c = a + b;
10
10
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
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
11
11
|
12
12
LL | let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
0 commit comments