Change:
The following code panics the compiler:
backtrace: <details</details
~Likely diagnostic related :-/~ Disregard that.
Slightly reduced: can also be , but I though this will remove one more warning, so it's worth using here ^^
triage: P-medium. removing nomination label. reasoning: you get the feature flag diagnostic, including the span of the offending code and the suggestion of what to write. So this is reasonable for users to deal with, even with the ICE. (as opposed to cases where the ICE occurs without any useful output for the user.)

Discussion:
) } <del> /// Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by /// removing the dummy `Self` type (`trait_object_dummy_self`). fn trait_ref_to_existential(&self, trait_ref: ty::TraitRef<'tcx>) -> ty::ExistentialTraitRef<'tcx> { if trait_ref.self_ty() != self.tcx().types.trait_object_dummy_self { bug!("trait_ref_to_existential called on {:?} with non-dummy Self", trait_ref); } ty::ExistentialTraitRef::erase_self_ty(self.tcx(), trait_ref) } </del> fn conv_object_ty_poly_trait_ref(&self, span: Span, trait_bounds: &[hir::PolyTraitRef],

debug!("regular_traits: {:?}", regular_traits); debug!("auto_traits: {:?}", auto_traits); <ins> // Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by // removing the dummy `Self` type (`trait_object_dummy_self`). let trait_ref_to_existential = |trait_ref: ty::TraitRef<'tcx>| { if trait_ref.self_ty() != dummy_self { // FIXME: There appears to be a missing filter on top of `expand_trait_aliases`, // which picks up non-supertraits where clauses - but also, the object safety // completely ignores trait aliases, which could be object safety hazards. We // `delay_span_bug` here to avoid an ICE in stable even when the feature is // disabled. (#66420) tcx.sess.delay_span_bug(DUMMY_SP, &format!( "trait_ref_to_existential called on {:?} with non-dummy Self", trait_ref, )); } ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref) }; </ins> // Erase the `dummy_self` (`trait_object_dummy_self`) used above. let existential_trait_refs = regular_traits.iter().map(|i| { <del> i.trait_ref().map_bound(|trait_ref| self.trait_ref_to_existential(trait_ref)) </del> <ins> i.trait_ref().map_bound(|trait_ref| trait_ref_to_existential(trait_ref)) </ins> }); let existential_projections = bounds.projection_bounds.iter().map(|(bound, _)| { bound.map_bound(|b| { <del> let trait_ref = self.trait_ref_to_existential(b.projection_ty.trait_ref(tcx)); </del> <ins> let trait_ref = trait_ref_to_existential(b.projection_ty.trait_ref(tcx)); </ins> ty::ExistentialProjection { ty: b.ty, item_def_id: b.projection_ty.item_def_id,

<ins> #![feature(trait_alias)] // Enabled to reduce stderr output, but can be triggered even if disabled. trait Trait {} trait WithType { type Ctx; } trait Alias<T> = where T: Trait; impl<T> WithType for T { type Ctx = dyn Alias<T>; //~^ ERROR the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time } fn main() {} </ins>

<ins> error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time --> $DIR/issue-65673.rs:9:5 | LL |     type Ctx; |          --- associated type defined here ... LL | impl<T> WithType for T { | ---------------------- in this `impl` item LL |     type Ctx = dyn Alias<T>; |     ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>