-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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
Consider the following example:
fn main() {
// mismatched types expected `char`, found `&str` rustc(E0308)
let my_character: char = "s";
}
The compiler could be more friendly in this case, having a diagnostic for suggesting using single quotes when people confuse single character strings with char literals. Something like this:
note: character literals are delimited by single quotes
--> main.rs:3:4
|
3 | let my_character: char = 's';
| ---
| |
| use single quotes here
This could help new Rust devs coming from languages where there are no distinction between these things. (Python, Javascript, etc.)
leonardo-m, ChrisCA, repi, Kobzol and dgiger42
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.