about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2024-12-05 20:16:48 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-02-05 11:02:49 +0000
commit476074888fca7d0abf6f6ee4e354d17118e3e48c (patch)
tree8ed580747e8ad29669562bbe231a71c4fbe808eb
parent8df89d1cb077cd76013d3f9f5a4e92c5b5a9280c (diff)
downloadrust-476074888fca7d0abf6f6ee4e354d17118e3e48c.tar.gz
rust-476074888fca7d0abf6f6ee4e354d17118e3e48c.zip
Document why some "type mismatches" exist
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index e90474cabb4..66f38deefba 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -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),