@@ -74,6 +74,10 @@ impl<D> TyBuilder<D> {
7474( self . data , subst)
7575}
7676
77+ pub fn build_into_subst ( self ) -> Substitution {
78+ self . build_internal ( ) . 1
79+ }
80+
7781pub fn push ( mut self , arg : impl CastTo < GenericArg > ) -> Self {
7882assert ! ( self . remaining( ) > 0 ) ;
7983let arg = arg. cast ( Interner ) ;
@@ -291,7 +295,6 @@ impl TyBuilder<hir_def::AdtId> {
291295) -> Self {
292296// Note that we're building ADT, so we never have parent generic parameters.
293297let defaults = db. generic_defaults ( self . data . into ( ) ) ;
294- let dummy_ty = TyKind :: Error . intern ( Interner ) . cast ( Interner ) ;
295298for default_ty in defaults. iter ( ) . skip ( self . vec . len ( ) ) {
296299// NOTE(skip_binders): we only check if the arg type is error type.
297300if let Some ( x) = default_ty. skip_binders ( ) . ty ( Interner ) {
@@ -301,13 +304,16 @@ impl TyBuilder<hir_def::AdtId> {
301304}
302305}
303306// Each default can only depend on the previous parameters.
304- // FIXME: we don't handle const generics here.
305307let subst_so_far = Substitution :: from_iter (
306308Interner ,
307309self . vec
308310. iter ( )
309311. cloned ( )
310- . chain ( iter:: repeat ( dummy_ty. clone ( ) ) )
312+ . chain ( self . param_kinds [ self . vec . len ( ) ..] . iter ( ) . map ( |it| match it {
313+ ParamKind :: Type => TyKind :: Error . intern ( Interner ) . cast ( Interner ) ,
314+ ParamKind :: Lifetime => error_lifetime ( ) . cast ( Interner ) ,
315+ ParamKind :: Const ( ty) => unknown_const_as_generic ( ty. clone ( ) ) ,
316+ } ) )
311317. take ( self . param_kinds . len ( ) ) ,
312318) ;
313319self . vec . push ( default_ty. clone ( ) . substitute ( Interner , & subst_so_far) . cast ( Interner ) ) ;
0 commit comments