Change:
<!-- [31mICE[0m: Rustc '-Zsanitizer=cfi -Ccodegen-units=1 -Clto -ooutputfile -Zdump-mir-dir=dir' 'error: internal compiler error: typeidforinstance: couldn't get fnabi of instance Layout(ReferencesError(ErrorGuaranteed(())))', 'error: internal compiler error: typeidforinstance: couldn't get fnabi of instance Layout(ReferencesError(ErrorGuaranteed(())))' File: --auto-reduced (treereduce-rust): &lt;details&lt;summary&lt;strongoriginal code&lt;/strong&lt;/summary&lt;poriginal: </p</detailsVersion information ` Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details<!-- query stack: --<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
cc
claim

Discussion:
.trait_item_def_id .expect("Part of a trait implementation, but not linked to the def_id?"); let trait_method = tcx.associated_item(method_id); <del> if traits::is_vtable_safe_method(tcx, trait_ref.skip_binder().def_id, trait_method) { </del> <ins> let trait_id = trait_ref.skip_binder().def_id; if traits::is_vtable_safe_method(tcx, trait_id, trait_method) && tcx.object_safety_violations(trait_id).is_empty() { </ins> // Trait methods will have a Self polymorphic parameter, where the concreteized // implementatation will not. We need to walk back to the more general trait method let trait_ref = tcx.instantiate_and_normalize_erasing_regions(

let fn_abi = tcx .fn_abi_of_instance(tcx.param_env(instance.def_id()).and((instance, ty::List::empty()))) <del> .unwrap_or_else(|instance| { bug!("typeid_for_instance: couldn't get fn_abi of instance {:?}", instance) </del> <ins> .unwrap_or_else(|error| { bug!("typeid_for_instance: couldn't get fn_abi of instance {instance:?}: {error:?}") </ins> }); typeid_for_fnabi(tcx, fn_abi, options)

tcx.mk_args_trait(new_rcvr, args.into_iter().skip(1)) } <ins> #[instrument(skip(tcx), ret)] </ins> fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tcx>) -> Ty<'tcx> { assert!(!poly_trait_ref.has_non_region_param()); let principal_pred = poly_trait_ref.map_bound(|trait_ref| {

ty::ParamEnv::reveal_all(), alias_ty.to_ty(tcx), ); <ins> debug!("Resolved {:?} -> {resolved}", alias_ty.to_ty(tcx)); </ins> ty::ExistentialPredicate::Projection(ty::ExistentialProjection { def_id: assoc_ty.def_id, args: ty::ExistentialTraitRef::erase_self_ty(tcx, super_trait_ref).args,

<ins> // Regression test for issue 123053, where associated types with lifetimes caused generation of the // trait object type to fail, causing an ICE. // //@ needs-sanitizer-cfi //@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass trait Iterable { type Item<'a> where Self: 'a; type Iter<'a>: Iterator<Item = Self::Item<'a>> where Self: 'a; fn iter<'a>(&'a self) -> Self::Iter<'a>; } impl<T> Iterable for [T] { type Item<'a> = <std::slice::Iter<'a, T> as Iterator>::Item where T: 'a; type Iter<'a> = std::slice::Iter<'a, T> where T: 'a; fn iter<'a>(&'a self) -> Self::Iter<'a> { self.iter() } } fn get_first<'a, I: Iterable + ?Sized>(it: &'a I) -> Option<I::Item<'a>> { it.iter().next() } fn main() { let v = vec![1, 2, 3]; assert_eq!(Some(&1), get_first(&*v)); } </ins>