diff options
| author | Jubilee <workingjubilee@gmail.com> | 2025-02-05 19:53:50 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-05 19:53:50 -0800 |
| commit | ffa67f9c445ac26d2513d8b6be5326dac955800a (patch) | |
| tree | e6e3054ae42d628141ca005ec555795aa1732eb8 | |
| parent | 8964e70051e1a033382c03557444b2fe11b9141b (diff) | |
| parent | 476074888fca7d0abf6f6ee4e354d17118e3e48c (diff) | |
| download | rust-ffa67f9c445ac26d2513d8b6be5326dac955800a.tar.gz rust-ffa67f9c445ac26d2513d8b6be5326dac955800a.zip | |
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.
| -rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs | 3 |
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), |
