1
Fork 0
rust/compiler/rustc_middle
Matthias Krüger 40f5861de9
Rollup merge of #135426 - compiler-errors:no-resolve-assoc-ty, r=lcnr
Assert that `Instance::try_resolve` is only used on body-like things

`Instance::resolve` is not set up to resolve items that are not body-like things. The logic in `resolve_associated_item` very much encodes this assumption:

e7ad3ae331/compiler/rustc_ty_utils/src/instance.rs (L96-L386)

However, some diagnostics were using `Instance::resolve` on an associated type, and it was simply a lucky coicidence that nothing went wrong.

This PR adds an assertion to make sure we won't do this again in the future, and fixes two callsites:
1. `call_kind` which returns a `CallKind` enum to categorize what a call in MIR comes from, and was using `Instance::resolve` to point at the associated type `Deref::Target` for a specific self ty.
2. `MirBorrowckCtxt::explain_deref_coercion`, which was doing the same thing.

The logic was replaced with `specialization_graph::assoc_def`, which is the proper way of fetching the right `AssocItem` for a given impl.

r? `@lcnr` or re-roll :)
2025-01-13 15:57:14 +01:00
..
src Rollup merge of #135426 - compiler-errors:no-resolve-assoc-ty, r=lcnr 2025-01-13 15:57:14 +01:00
Cargo.toml best_blame_constraint: prioritize blaming interesting-seeming constraints 2025-01-06 16:12:11 -08:00
messages.ftl Move some code from Compiler::enter to GlobalCtxt::finish 2024-11-09 17:55:39 +00:00
README.md

For more information about how rustc works, see the rustc dev guide.