X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fcheck%2Fdemand.rs;h=b7e276b69656f84d397f0c74e6d0f67f618868f8;hb=2411cd7c7abd3a4d4aba657961ca1f940e1657bd;hp=b210c78cae007989d7ea08f895bebc42dab1da13;hpb=e6b883c74f49f32cb5d1cbad3457f2b8805a4a38;p=rust.git diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index b210c78cae0..b7e276b6965 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -1264,6 +1264,18 @@ pub fn check_for_cast( } true } + ( + &ty::Uint(ty::UintTy::U32 | ty::UintTy::U64 | ty::UintTy::U128) + | &ty::Int(ty::IntTy::I32 | ty::IntTy::I64 | ty::IntTy::I128), + &ty::Char, + ) => { + err.multipart_suggestion_verbose( + &format!("{}, since a `char` always occupies 4 bytes", cast_msg,), + cast_suggestion, + Applicability::MachineApplicable, + ); + true + } _ => false, } }