1
Fork 0

Make compare_impl_item into a query

This commit is contained in:
Michael Goulet 2024-11-23 04:48:01 +00:00
parent e48ddd8a0b
commit a3623f20ae
16 changed files with 84 additions and 228 deletions

View file

@ -216,15 +216,13 @@ fn resolve_associated_item<'tcx>(
let args = tcx.erase_regions(args);
// Check if we just resolved an associated `const` declaration from
// a `trait` to an associated `const` definition in an `impl`, where
// the definition in the `impl` has the wrong type (for which an
// error has already been/will be emitted elsewhere).
if leaf_def.item.kind == ty::AssocKind::Const
&& trait_item_id != leaf_def.item.def_id
// We check that the impl item is compatible with the trait item
// because otherwise we may ICE in const eval due to type mismatches,
// signature incompatibilities, etc.
if trait_item_id != leaf_def.item.def_id
&& let Some(leaf_def_item) = leaf_def.item.def_id.as_local()
{
tcx.compare_impl_const((leaf_def_item, trait_item_id))?;
tcx.ensure().compare_impl_item(leaf_def_item)?;
}
Some(ty::Instance::new(leaf_def.item.def_id, args))