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
This was likely introduced in (CC rustc 1.65 nightly 2022-08-12 emits the following:

Discussion:
use rustc_span::edition::Edition; use rustc_span::lev_distance::find_best_match_for_name; use rustc_span::symbol::{kw, Ident, Symbol}; <del> use rustc_span::{Span, DUMMY_SP}; </del> <ins> use rustc_span::Span; </ins> use rustc_target::spec::abi; use rustc_trait_selection::traits; use rustc_trait_selection::traits::astconv_object_safety_violations;

.enumerate() .skip(1) // Remove `Self` for `ExistentialPredicate`. .map(|(index, arg)| { <del> if let ty::GenericArgKind::Type(ty) = arg.unpack() { debug!(?ty); if ty == dummy_self { let param = &generics.params[index]; missing_type_params.push(param.name); tcx.ty_error().into() } else if ty.walk().any(|arg| arg == dummy_self.into()) { references_self = true; tcx.ty_error().into() } else { arg } } else { arg </del> <ins> if arg == dummy_self.into() { let param = &generics.params[index]; missing_type_params.push(param.name); return tcx.ty_error().into(); } else if arg.walk().any(|arg| arg == dummy_self.into()) { references_self = true; return tcx.ty_error().into(); </ins> } <ins> arg </ins> }) .collect(); let substs = tcx.intern_substs(&substs[..]);

}); let existential_projections = bounds.projection_bounds.iter().map(|(bound, _)| { <del> bound.map_bound(|b| { if b.projection_ty.self_ty() != dummy_self { tcx.sess.delay_span_bug( DUMMY_SP, &format!("trait_ref_to_existential called on {:?} with non-dummy Self", b), ); </del> <ins> bound.map_bound(|mut b| { assert_eq!(b.projection_ty.self_ty(), dummy_self); // Like for trait refs, verify that `dummy_self` did not leak inside default type // parameters. let references_self = b.projection_ty.substs.iter().skip(1).any(|arg| { if arg.walk().any(|arg| arg == dummy_self.into()) { return true; } false }); if references_self { tcx.sess .delay_span_bug(span, "trait object projection bounds reference `Self`"); let substs: Vec<_> = b .projection_ty .substs .iter() .map(|arg| { if arg.walk().any(|arg| arg == dummy_self.into()) { return tcx.ty_error().into(); } arg }) .collect(); b.projection_ty.substs = tcx.intern_substs(&substs[..]); </ins> } ty::ExistentialProjection::erase_self_ty(tcx, b) }) });

<ins> #![allow(incomplete_features)] #![feature(generic_const_exprs)] #![feature(trait_alias)] trait Bar<const N: usize> {} trait BB = Bar<{ 2 + 1 }>; fn foo(x: &dyn BB) {} //~^ ERROR the trait alias `BB` cannot be made into an object [E0038] fn main() {} </ins>

<ins> error[E0038]: the trait alias `BB` cannot be made into an object --> $DIR/self-in-const-generics.rs:9:16 | LL | fn foo(x: &dyn BB) {} |                ^^ | = note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause error: aborting due to previous error For more information about this error, try `rustc --explain E0038`. </ins>

<ins> // astconv uses `FreshTy(0)` as a dummy `Self` type when instanciating trait objects. // This `FreshTy(0)` can leak into substs, causing ICEs in several places. // Using `save-analysis` triggers type-checking `f` that would be normally skipped // as `type_of` emitted an error. // // compile-flags: -Zsave-analysis </ins> #![feature(trait_alias)] pub trait SelfInput = Fn(&mut Self);

error[E0038]: the trait alias `SelfInput` cannot be made into an object <del> --> $DIR/self-in-generics.rs:5:19 </del> <ins> --> $DIR/self-in-generics.rs:12:19 </ins> | LL | pub fn f(_f: &dyn SelfInput) {} |                   ^^^^^^^^^