Skip to content

Commit

Permalink
Rollup merge of #120972 - lukas-code:autoderef-type-error, r=compiler…
Browse files Browse the repository at this point in the history
…-errors

fix ICE for deref coercions with type errors

Follow-up to rust-lang/rust#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 (rust-lang/rust#120550).

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

https://github.com/rust-lang/rust/blob/b17491c8f6d555386104dfd82004c01bfef09c95/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 rust-lang/rust#120945

r? ``@compiler-errors`` or compiler
  • Loading branch information
matthiaskrgr committed Feb 12, 2024
2 parents ac9ce77 + 97b4401 commit 80d3eef
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 80d3eef

Please sign in to comment.