From 40d132f0f826b0f0ae203219ab30d23da8f55573 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 24 Jul 2024 22:59:38 -0400 Subject: Make sure that args are compatible in resolve_associated_item --- compiler/rustc_ty_utils/src/instance.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_ty_utils/src/instance.rs') diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 7b6d86d22a5..a2bed61a7ae 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -191,11 +191,22 @@ fn resolve_associated_item<'tcx>( // Any final impl is required to define all associated items. if !leaf_def.item.defaultness(tcx).has_value() { - let guard = tcx.dcx().span_delayed_bug( + let guar = tcx.dcx().span_delayed_bug( tcx.def_span(leaf_def.item.def_id), "missing value for assoc item in impl", ); - return Err(guard); + return Err(guar); + } + + // Make sure that we're projecting to an item that has compatible args. + // This may happen if we are resolving an instance before codegen, such + // as during inlining. This check is also done in projection. + if !tcx.check_args_compatible(leaf_def.item.def_id, args) { + let guar = tcx.dcx().span_delayed_bug( + tcx.def_span(leaf_def.item.def_id), + "missing value for assoc item in impl", + ); + return Err(guar); } let args = tcx.erase_regions(args); -- cgit 1.4.1-3-g733a5