about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-28 07:17:38 +0000
committerbors <bors@rust-lang.org>2023-07-28 07:17:38 +0000
commit037844c8a032db23676c8caff59d623c4bad873a (patch)
treecff0ffa504fb148722faf3459259fc340e0d3e2b /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentbc1b0bfa7fd8188e207976485a841dc6c37b4f94 (diff)
parent074488b290732092d077c8271fdcc2c6a91ecede (diff)
downloadrust-037844c8a032db23676c8caff59d623c4bad873a.tar.gz
rust-037844c8a032db23676c8caff59d623c4bad873a.zip
Auto merge of #15271 - lowr:patch/re-castable, r=HKalbasi
Properly infer types with type casts

This PR reenables `Expectation::Castable` (previous attempt at #14104, reverted by #14120) and implements type cast checks, which enable us to infer a bit more.

Castable expectations are relatively weak -- they only influence the inference if we cannot infer the types by other means. Therefore, we need to defer possible type unification with the casted type until we type check all expressions of the body. This PR adds a struct and slots in `InferenceContext` for the deferred cast checks (c.f. [`CastCheck`] in `rustc_hir_typeck`).

I only implemented the bits that affect the inference result. It should be possible to return type adjustments for well-formed casts and report diagnostics for invalid casts, but I'm leaving them for future work for now.

Fixes #11571
Fixes #15246

[`CastCheck`]: https://github.com/rust-lang/rust/blob/da1d099f91ea387a2814a6244dd875a2048b486f/compiler/rustc_hir_typeck/src/cast.rs#L55
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions