@@ -352,7 +352,11 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
352352 } )
353353 . intern ( interner)
354354 }
355- Dynamic ( _, _) => unimplemented ! ( ) ,
355+ // FIXME(chalk): add region
356+ Dynamic ( predicates, _region) => {
357+ TyData :: Dyn ( chalk_ir:: DynTy { bounds : predicates. lower_into ( interner) } )
358+ . intern ( interner)
359+ }
356360 Closure ( _def_id, _) => unimplemented ! ( ) ,
357361 Generator ( _def_id, _substs, _) => unimplemented ! ( ) ,
358362 GeneratorWitness ( _) => unimplemented ! ( ) ,
@@ -361,7 +365,13 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
361365 apply ( chalk_ir:: TypeName :: Tuple ( substs. len ( ) ) , substs. lower_into ( interner) )
362366 }
363367 Projection ( proj) => TyData :: Alias ( proj. lower_into ( interner) ) . intern ( interner) ,
364- Opaque ( _def_id, _substs) => unimplemented ! ( ) ,
368+ Opaque ( def_id, substs) => {
369+ TyData :: Alias ( chalk_ir:: AliasTy :: Opaque ( chalk_ir:: OpaqueTy {
370+ opaque_ty_id : chalk_ir:: OpaqueTyId ( RustDefId :: Opaque ( def_id) ) ,
371+ substitution : substs. lower_into ( interner) ,
372+ } ) )
373+ . intern ( interner)
374+ }
365375 // This should have been done eagerly prior to this, and all Params
366376 // should have been substituted to placeholders
367377 Param ( _) => panic ! ( "Lowering Param when not expected." ) ,
@@ -376,7 +386,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
376386 } )
377387 . intern ( interner) ,
378388 Infer ( _infer) => unimplemented ! ( ) ,
379- Error ( _) => unimplemented ! ( ) ,
389+ Error ( _) => apply ( chalk_ir :: TypeName :: Error , empty ( ) ) ,
380390 }
381391 }
382392}
@@ -401,6 +411,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'t
401411 ty:: BrEnv => unimplemented ! ( ) ,
402412 } ,
403413 ReFree ( _) => unimplemented ! ( ) ,
414+ // FIXME(chalk): need to handle ReStatic
404415 ReStatic => unimplemented ! ( ) ,
405416 ReVar ( _) => unimplemented ! ( ) ,
406417 RePlaceholder ( placeholder_region) => {
@@ -411,6 +422,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'t
411422 . intern ( interner)
412423 }
413424 ReEmpty ( _) => unimplemented ! ( ) ,
425+ // FIXME(chalk): need to handle ReErased
414426 ReErased => unimplemented ! ( ) ,
415427 }
416428 }
@@ -472,6 +484,39 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
472484 }
473485}
474486
487+ impl < ' tcx > LowerInto < ' tcx , chalk_ir:: Binders < chalk_ir:: QuantifiedWhereClauses < RustInterner < ' tcx > > > >
488+ for Binder < & ' tcx ty:: List < ty:: ExistentialPredicate < ' tcx > > >
489+ {
490+ fn lower_into (
491+ self ,
492+ interner : & RustInterner < ' tcx > ,
493+ ) -> chalk_ir:: Binders < chalk_ir:: QuantifiedWhereClauses < RustInterner < ' tcx > > > {
494+ let ( predicates, binders, _named_regions) =
495+ collect_bound_vars ( interner, interner. tcx , & self ) ;
496+ let where_clauses = predicates. into_iter ( ) . map ( |predicate| match predicate {
497+ ty:: ExistentialPredicate :: Trait ( ty:: ExistentialTraitRef { def_id, substs } ) => {
498+ chalk_ir:: Binders :: new (
499+ chalk_ir:: ParameterKinds :: new ( interner) ,
500+ chalk_ir:: WhereClause :: Implemented ( chalk_ir:: TraitRef {
501+ trait_id : chalk_ir:: TraitId ( RustDefId :: Trait ( * def_id) ) ,
502+ substitution : substs. lower_into ( interner) ,
503+ } ) ,
504+ )
505+ }
506+ ty:: ExistentialPredicate :: Projection ( _predicate) => unimplemented ! ( ) ,
507+ ty:: ExistentialPredicate :: AutoTrait ( def_id) => chalk_ir:: Binders :: new (
508+ chalk_ir:: ParameterKinds :: new ( interner) ,
509+ chalk_ir:: WhereClause :: Implemented ( chalk_ir:: TraitRef {
510+ trait_id : chalk_ir:: TraitId ( RustDefId :: Trait ( * def_id) ) ,
511+ substitution : chalk_ir:: Substitution :: empty ( interner) ,
512+ } ) ,
513+ ) ,
514+ } ) ;
515+ let value = chalk_ir:: QuantifiedWhereClauses :: from ( interner, where_clauses) ;
516+ chalk_ir:: Binders :: new ( binders, value)
517+ }
518+ }
519+
475520/// To collect bound vars, we have to do two passes. In the first pass, we
476521/// collect all `BoundRegion`s and `ty::Bound`s. In the second pass, we then
477522/// replace `BrNamed` into `BrAnon`. The two separate passes are important,
0 commit comments