-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code:
fn main() {
let greeting = "Hello, World!";
let mut output = 0;
for c in greeting.chars() {
output += c;
}
println!("The values of the characters in \"{greeting}\" sum to {output}");
}
The current output is:
error[E0277]: cannot add-assign `char` to `{integer}`
--> src/main.rs:5:10
|
5 | output += c;
| ^^ no implementation for `{integer} += char`
|
= help: the trait `AddAssign<char>` is not implemented for `{integer}`
For more information about this error, try `rustc --explain E0277`.
Ideally the output should look like:
error[E0277]: cannot add-assign `char` to `{integer}`
--> src/main.rs:5:10
|
5 | output += c;
| ^^ no implementation for `{integer} += char`
|
= help: the trait `AddAssign<char>` is not implemented for `{integer}`. You may have meant to use `as u32` or `to_digit` on the `char`.
For more information about this error, try `rustc --explain E0277`.
SamuelBonilla and workingjubilee
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.