Change:
Continuation of . I minimized this together with thank you for your help and originally finding the issue! <!-- 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. --: The first and most relevant delayed bug: All the delayed bugs and the usual backtrace: <details<summary<strongBacktrace</strong</summary<p</p</details
Regressed the the PR: searched nightlies: from nightly-2021-01-01 to nightly-2022-12-12 regressed nightly: nightly-2022-11-27 searched commit range: regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.4</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </details

Discussion:
tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, ) -> SubstsRef<'tcx> { <del> tcx.mk_substs(substs.iter().enumerate().map(|(idx, arg)| { match arg.unpack() { GenericArgKind::Type(_) if arg.has_non_region_param() || arg.has_non_region_infer() => { tcx.mk_ty(ty::Placeholder(ty::PlaceholderType { </del> <ins> struct ReplaceParamAndInferWithPlaceholder<'tcx> { tcx: TyCtxt<'tcx>, idx: usize, } impl<'tcx> TypeFolder<'tcx> for ReplaceParamAndInferWithPlaceholder<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> { self.tcx } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { if let ty::Infer(_) = t.kind() { self.tcx.mk_ty(ty::Placeholder(ty::PlaceholderType { </ins> universe: ty::UniverseIndex::ROOT, <del> name: ty::BoundVar::from_usize(idx), </del> <ins> name: ty::BoundVar::from_usize({ let idx = self.idx; self.idx += 1; idx }), </ins> })) <del> .into() </del> <ins> } else { t.super_fold_with(self) </ins> } <del> GenericArgKind::Const(ct) if ct.has_non_region_infer() || ct.has_non_region_param() => { let ty = ct.ty(); // If the type references param or infer, replace that too... </del> <ins> } fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> { if let ty::ConstKind::Infer(_) = c.kind() { let ty = c.ty(); // If the type references param or infer then ICE ICE ICE </ins> if ty.has_non_region_param() || ty.has_non_region_infer() { <del> bug!("const `{ct}`'s type should not reference params or types"); </del> <ins> bug!("const `{c}`'s type should not reference params or types"); </ins> } <del> tcx.mk_const( </del> <ins> self.tcx.mk_const( </ins> ty::PlaceholderConst { universe: ty::UniverseIndex::ROOT, <del> name: ty::BoundVar::from_usize(idx), </del> <ins> name: ty::BoundVar::from_usize({ let idx = self.idx; self.idx += 1; idx }), </ins> }, ty, ) <del> .into() </del> <ins> } else { c.super_fold_with(self) </ins> } <del> _ => arg, </del> } <del> })) </del> <ins> } substs.fold_with(&mut ReplaceParamAndInferWithPlaceholder { tcx, idx: 0 }) </ins> }

<ins> #![feature(generic_const_exprs)] #![allow(incomplete_features)] struct Combination<const STRATEGIES: usize>; impl<const STRATEGIES: usize> Combination<STRATEGIES> { fn and<M>(self) -> Combination<{ STRATEGIES + 1 }> { Combination } } pub fn main() { Combination::<0>.and::<_>().and::<_>(); //~^ ERROR: type annotations needed } </ins>

<ins> error[E0282]: type annotations needed --> $DIR/issue-105608.rs:13:22 | LL |     Combination::<0>.and::<_>().and::<_>(); |                      ^^^ cannot infer type of the type parameter `M` declared on the associated function `and` | help: consider specifying the generic argument | LL |     Combination::<0>.and::<_>().and::<_>(); |                         ~~~~~ error: aborting due to previous error For more information about this error, try `rustc --explain E0282`. </ins>