Skip to content

Commit ffa67f9

Browse files
Rollup merge of #136573 - oli-obk:document-literal-at-wrong-type-reason, r=compiler-errors
Document why some "type mismatches" exist Just something I stumbled over and thought to save myself (and maybe others) the research time when encountering it again.
2 parents 8964e70 + 4760748 commit ffa67f9

File tree

1 file changed

+3
-0
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt

1 file changed

+3
-0
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16191619
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
16201620
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() {
16211621
ty::Int(_) | ty::Uint(_) => Some(ty),
1622+
// These exist to direct casts like `0x61 as char` to use
1623+
// the right integer type to cast from, instead of falling back to
1624+
// i32 due to no further constraints.
16221625
ty::Char => Some(tcx.types.u8),
16231626
ty::RawPtr(..) => Some(tcx.types.usize),
16241627
ty::FnDef(..) | ty::FnPtr(..) => Some(tcx.types.usize),

0 commit comments

Comments
 (0)