-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle more string addition cases with appropriate suggestions #60901
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
| ^^^^^^^^^^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems better, yeah.
r? @varkor |
r? @Centril |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.