about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/instance.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-11-23 04:48:01 +0000
committerMichael Goulet <michael@errs.io>2024-11-30 16:45:01 +0000
commita3623f20ae18996f31cc4a5a431d8afaa382247e (patch)
tree89318c4c129bf316d88e829e334a4a3a8854e18e /compiler/rustc_ty_utils/src/instance.rs
parente48ddd8a0bbd1769587017f04c518d686ea3b206 (diff)
downloadrust-a3623f20ae18996f31cc4a5a431d8afaa382247e.tar.gz
rust-a3623f20ae18996f31cc4a5a431d8afaa382247e.zip
Make compare_impl_item into a query
Diffstat (limited to 'compiler/rustc_ty_utils/src/instance.rs')
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 1a98c85bee9..ede671b0f0f 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -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))