mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Document why some "type mismatches" exist
This commit is contained in:
parent
8df89d1cb0
commit
476074888f
@ -1619,6 +1619,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => Some(ty),
|
||||
// These exist to direct casts like `0x61 as char` to use
|
||||
// the right integer type to cast from, instead of falling back to
|
||||
// i32 due to no further constraints.
|
||||
ty::Char => Some(tcx.types.u8),
|
||||
ty::RawPtr(..) => Some(tcx.types.usize),
|
||||
ty::FnDef(..) | ty::FnPtr(..) => Some(tcx.types.usize),
|
||||
|
Loading…
Reference in New Issue
Block a user