Skip to content

Show better warning for trying to cast non-u8 scalar to char #44201

Closed
@Manishearth

Description

@Manishearth
fn main() {
    const XYZ: char = 0xEF8888 as char;
    println!("{}", XYZ);
}

Will warn "literal is out of range for u8" because u8 is the only as char cast that is acceptable.

We should show a better warning and suggest the \u syntax instead.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions