Handle more string addition cases with appropriate suggestions#60901
Handle more string addition cases with appropriate suggestions#60901bors merged 4 commits intorust-lang:masterfrom
Conversation
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
| | | | | ||
| | | `+` can't be used to concatenate two `&str` strings | ||
| | &std::string::String | ||
| 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 |
There was a problem hiding this comment.
I feel a bit of information overload here; there's too much information packed in too little space. I'd consider giving things more "air" by e.g. moving help: down a line.
There was a problem hiding this comment.
There was a problem hiding this comment.
Hmm, it would have been nice to have a method on DiagnosticBuilder that forces a newline... but since it happens elsewhere... bummer! and let's move on.
I do agree colors make it less of a problem, but that still makes me somewhat dizzy.
There was a problem hiding this comment.
Yeah, these look much better when the text is much shorter than this. What we could do is make the help text short and only say what it should do (fix the types of the binop), and have a separate note talk about this, which would introduce a newline and look like this
error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
--> $DIR/issue-39018.rs:33:15
|
LL | let _ = e + &d;
| - ^ -- &&str
| | |
| | `+` cannot be used to concatenate two `&str` strings
| &std::string::String
= note: string concatenation appends the string on the right to the string on the left and may require reallocation, and this requires ownership of the string on the left
help: turn the string in the lift into a `String`
|
LL | let _ = e.to_owned() + &d;
| ^^^^^^^^^^^^
|
r? @varkor |
|
r? @Centril |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
r=me assuming you are happy with how things are in #60901 (comment).
We can always adjust later if people complain...
|
@bors r=Centril |
|
📌 Commit ee0bf5e has been approved by |
|
📌 Commit 8895fb9 has been approved by |
Handle more string addition cases with appropriate suggestions

No description provided.