Skip to content

Commit

Permalink
Point out that char is 32 bit value
Browse files Browse the repository at this point in the history
  • Loading branch information
fhartwig committed Jan 27, 2016
1 parent 23dfb2f commit cee96fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/types.rs
Expand Up @@ -544,7 +544,9 @@ impl LateLintPass for CharLitAsU8 {
if let ExprLit(ref l) = e.node {
if let Lit_::LitChar(_) = l.node {
if ty::TyUint(UintTy::TyU8) == cx.tcx.expr_ty(expr).sty && !in_macro(cx, expr.span) {
let msg = "casting character literal to u8.";
let msg = "casting character literal to u8. `char`s \
are 4 bytes wide in rust, so casting to u8 \
truncates them";
let help = format!("Consider using a byte literal \
instead:\nb{}",
snippet(cx, e.span, "'x'"));
Expand Down

0 comments on commit cee96fa

Please sign in to comment.