Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
probably Regression in searched nightlies: from nightly-2023-02-15 to nightly-2023-03-16 regressed nightly: nightly-2023-02-20 searched commit range: regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.5</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </details
It's actually
Or at least, the logic broke because of , so the ICE message probably changed in that PR from some other message, to this one in the title.
label +S-bug-has-mcve

Discussion:
// Region folder impl<'tcx> TyCtxt<'tcx> { <del> /// Folds the escaping and free regions in `value` using `f`, and /// sets `skipped_regions` to true if any late-bound region was found /// and skipped. </del> <ins> /// Folds the escaping and free regions in `value` using `f`. </ins> pub fn fold_regions<T>( self, value: T,

{ value.fold_with(&mut RegionFolder::new(self, &mut f)) } <del> pub fn super_fold_regions<T>( self, value: T, mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>, ) -> T where T: TypeSuperFoldable<TyCtxt<'tcx>>, { value.super_fold_with(&mut RegionFolder::new(self, &mut f)) } </del> } /// Folds over the substructure of a type, visiting its component

TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_session::config::TraitSolver; <del> use rustc_span::def_id::{DefId, CRATE_DEF_ID}; </del> <ins> use rustc_span::{ def_id::{DefId, CRATE_DEF_ID}, DUMMY_SP, }; </ins> use rustc_trait_selection::traits; fn sized_constraint_for_ty<'tcx>(

} fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> { <del> if let ty::Alias(ty::Projection, alias_ty) = *ty.kind() && self.tcx.is_impl_trait_in_trait(alias_ty.def_id) && self.tcx.impl_trait_in_trait_parent_fn(alias_ty.def_id) == self.fn_def_id && self.seen.insert(alias_ty.def_id) </del> <ins> if let ty::Alias(ty::Projection, unshifted_alias_ty) = *ty.kind() && self.tcx.is_impl_trait_in_trait(unshifted_alias_ty.def_id) && self.tcx.impl_trait_in_trait_parent_fn(unshifted_alias_ty.def_id) == self.fn_def_id && self.seen.insert(unshifted_alias_ty.def_id) </ins> { // We have entered some binders as we've walked into the // bounds of the RPITIT. Shift these binders back out when // constructing the top-level projection predicate. <del> let alias_ty = self.tcx.fold_regions(alias_ty, |re, _| { </del> <ins> let shifted_alias_ty = self.tcx.fold_regions(unshifted_alias_ty, |re, depth| { </ins> if let ty::ReLateBound(index, bv) = re.kind() { <ins> if depth != ty::INNERMOST { return self.tcx.mk_re_error_with_message( DUMMY_SP, "we shouldn't walk non-predicate binders with `impl Trait`...", ); } </ins> self.tcx.mk_re_late_bound(index.shifted_out_to_binder(self.depth), bv) } else { re

// the `type_of` of the trait's associated item. If we're using the old lowering // strategy, then just reinterpret the associated type like an opaque :^) let default_ty = if self.tcx.lower_impl_trait_in_trait_to_assoc_ty() { <del> self .tcx .type_of(alias_ty.def_id) .subst(self.tcx, alias_ty.substs) </del> <ins> self.tcx.type_of(shifted_alias_ty.def_id).subst(self.tcx, shifted_alias_ty.substs) </ins> } else { <del> self.tcx.mk_alias(ty::Opaque, alias_ty) </del> <ins> self.tcx.mk_alias(ty::Opaque, shifted_alias_ty) </ins> }; self.predicates.push( ty::Binder::bind_with_vars( <del> ty::ProjectionPredicate { projection_ty: alias_ty, term: default_ty.into(), }, </del> <ins> ty::ProjectionPredicate { projection_ty: shifted_alias_ty, term: default_ty.into() }, </ins> self.bound_vars, ) .to_predicate(self.tcx), ); <del> for bound in self.tcx.item_bounds(alias_ty.def_id).subst_iter(self.tcx, alias_ty.substs) </del> <ins> // We walk the *un-shifted* alias ty, because we're tracking the de bruijn // binder depth, and if we were to walk `shifted_alias_ty` instead, we'd // have to reset `self.depth` back to `ty::INNERMOST` or something. It's // easier to just do this. for bound in self .tcx .item_bounds(unshifted_alias_ty.def_id) .subst_iter(self.tcx, unshifted_alias_ty.substs) </ins> { bound.visit_with(self); }

fn method(&self) -> impl Trait<Type = impl Sized + '_>; } <ins> trait Trait2 { type Type; fn method(&self) -> impl Trait2<Type = impl Trait2<Type = impl Sized + '_> + '_>; } </ins> fn main() {}