1
Fork 0
rust/compiler/rustc_hir_analysis/src
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
..
astconv hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
check Rollup merge of #120972 - lukas-code:autoderef-type-error, r=compiler-errors 2024-02-12 18:04:11 +01:00
coherence Auto merge of #120835 - oli-obk:no_hir_coherence, r=cjgillot 2024-02-12 07:28:13 +00:00
collect hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
impl_wf_check remove a bunch of dead parameters in fn 2024-02-12 09:51:35 +08:00
outlives Stop using track_errors for some forever unstable rustc_attr analyses 2024-01-17 10:02:14 +00:00
structured_errors hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
variance Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
autoderef.rs fix ICE for deref coercions with type errors 2024-02-12 14:37:35 +01:00
bounds.rs ~const trait or projection bounds do not imply non-const bounds 2024-01-08 15:01:14 +00:00
check_unused.rs Rename TyCtxt::struct_span_lint_hir as TyCtxt::node_span_lint. 2024-01-23 08:09:01 +11:00
collect.rs hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
constrained_generic_params.rs finish RegionKind rename 2023-11-14 13:13:27 +00:00
errors.rs Make the error message better 2024-02-05 21:08:47 +00:00
hir_wf_check.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
impl_wf_check.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
lib.rs Remove unnecessary min_specialization after bootstrap 2024-02-10 18:15:11 +11:00
structured_errors.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00