rust/compiler/rustc_hir_analysis
Matthias Krüger 8e5f722ece
Rollup merge of #120972 - lukas-code:autoderef-type-error, r=compiler-errors
fix ICE for deref coercions with type errors

Follow-up to https://github.com/rust-lang/rust/pull/120895, where I made types with errors go through the full coercion code, which is necessary if we want to build MIR for bodies with errors (https://github.com/rust-lang/rust/pull/120550).

The code for coercing `&T` to `&U` currently assumes that autoderef for `&T` will succeed for at least two steps (`&T` and `T`):

b17491c8f6/compiler/rustc_hir_typeck/src/coercion.rs (L339-L464)

But for types with errors, we previously only returned the no-op autoderef step (`&{type error}` -> `&{type error}`) and then stopped early. This PR changes autoderef for types with errors to still go through the built-in derefs (e.g. `&&{type error}` -> `&{type error}` -> `{type error}`) and only stop early when it would have to go looking for `Deref` trait impls.

fixes https://github.com/rust-lang/rust/issues/120945

r? ``@compiler-errors`` or compiler
2024-02-12 18:04:11 +01:00
..
src Rollup merge of #120972 - lukas-code:autoderef-type-error, r=compiler-errors 2024-02-12 18:04:11 +01:00
Cargo.toml Use zip_eq to enforce that things being zipped have equal sizes 2024-01-14 20:01:12 +00:00
messages.ftl Make the error message better 2024-02-05 21:08:47 +00:00
README.md

For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.