@@ -25,7 +25,7 @@ use chalk_ir::{
2525use either:: Either ;
2626use hir_def:: {
2727 AdtId , AssocItemId , ConstId , ConstParamId , EnumId , EnumVariantId , FunctionId , GenericDefId ,
28- GenericParamId , ImplId , ItemContainerId , LocalFieldId , Lookup , StaticId , StructId , TypeAliasId ,
28+ GenericParamId , ItemContainerId , LocalFieldId , Lookup , StaticId , StructId , TypeAliasId ,
2929 TypeOrConstParamId , UnionId , VariantId ,
3030 builtin_type:: BuiltinType ,
3131 expr_store:: { ExpressionStore , path:: Path } ,
@@ -34,8 +34,8 @@ use hir_def::{
3434 resolver:: { HasResolver , LifetimeNs , Resolver , TypeNs } ,
3535 signatures:: { FunctionSignature , TraitFlags } ,
3636 type_ref:: {
37- ConstRef , LifetimeRefId , LiteralConstRef , PathId , TraitBoundModifier ,
38- TraitRef as HirTraitRef , TypeBound , TypeRef , TypeRefId ,
37+ ConstRef , LifetimeRefId , LiteralConstRef , PathId , TraitBoundModifier , TypeBound , TypeRef ,
38+ TypeRefId ,
3939 } ,
4040} ;
4141use hir_expand:: name:: Name ;
@@ -59,6 +59,10 @@ use crate::{
5959 } ,
6060 make_binders,
6161 mapping:: { from_chalk_trait_id, lt_to_placeholder_idx} ,
62+ next_solver:: {
63+ DbInterner ,
64+ mapping:: { ChalkToNextSolver , NextSolverToChalk } ,
65+ } ,
6266 static_lifetime, to_chalk_trait_id, to_placeholder_idx,
6367 utils:: all_super_trait_refs,
6468 variable_kinds_from_iter,
@@ -565,14 +569,6 @@ impl<'a> TyLoweringContext<'a> {
565569 Some ( ( ctx. lower_trait_ref_from_resolved_path ( resolved, explicit_self_ty, false ) , ctx) )
566570 }
567571
568- fn lower_trait_ref (
569- & mut self ,
570- trait_ref : & HirTraitRef ,
571- explicit_self_ty : Ty ,
572- ) -> Option < TraitRef > {
573- self . lower_trait_ref_from_path ( trait_ref. path , explicit_self_ty) . map ( |it| it. 0 )
574- }
575-
576572 /// When lowering predicates from parents (impl, traits) for children defs (fns, consts, types), `generics` should
577573 /// contain the `Generics` for the **child**, while `predicate_owner` should contain the `GenericDefId` of the
578574 /// **parent**. This is important so we generate the correct bound var/placeholder.
@@ -851,21 +847,21 @@ fn named_associated_type_shorthand_candidates<R>(
851847 } )
852848 } ;
853849
850+ let interner = DbInterner :: new_with ( db, None , None ) ;
854851 match res {
855852 TypeNs :: SelfType ( impl_id) => {
856- // we're _in_ the impl -- the binders get added back later. Correct,
857- // but it would be nice to make this more explicit
858- let trait_ref = db. impl_trait ( impl_id) ?. into_value_and_skipped_binders ( ) . 0 ;
853+ let trait_ref = db. impl_trait ( impl_id) ?;
859854
860855 let impl_id_as_generic_def: GenericDefId = impl_id. into ( ) ;
861856 if impl_id_as_generic_def != def {
862857 let subst = TyBuilder :: subst_for_def ( db, impl_id, None )
863858 . fill_with_bound_vars ( DebruijnIndex :: INNERMOST , 0 )
864859 . build ( ) ;
865- let trait_ref = subst. apply ( trait_ref, Interner ) ;
860+ let args: crate :: next_solver:: GenericArgs < ' _ > = subst. to_nextsolver ( interner) ;
861+ let trait_ref = trait_ref. instantiate ( interner, args) . to_chalk ( interner) ;
866862 search ( trait_ref)
867863 } else {
868- search ( trait_ref)
864+ search ( trait_ref. skip_binder ( ) . to_chalk ( interner ) )
869865 }
870866 }
871867 TypeNs :: GenericParam ( param_id) => {
@@ -1335,31 +1331,6 @@ impl ValueTyDefId {
13351331 }
13361332}
13371333
1338- pub ( crate ) fn impl_self_ty_query ( db : & dyn HirDatabase , impl_id : ImplId ) -> Binders < Ty > {
1339- impl_self_ty_with_diagnostics_query ( db, impl_id) . 0
1340- }
1341-
1342- pub ( crate ) fn impl_self_ty_with_diagnostics_query (
1343- db : & dyn HirDatabase ,
1344- impl_id : ImplId ,
1345- ) -> ( Binders < Ty > , Diagnostics ) {
1346- let impl_data = db. impl_signature ( impl_id) ;
1347- let resolver = impl_id. resolver ( db) ;
1348- let generics = generics ( db, impl_id. into ( ) ) ;
1349- let mut ctx = TyLoweringContext :: new (
1350- db,
1351- & resolver,
1352- & impl_data. store ,
1353- impl_id. into ( ) ,
1354- LifetimeElisionKind :: AnonymousCreateParameter { report_in_path : true } ,
1355- )
1356- . with_type_param_mode ( ParamLoweringMode :: Variable ) ;
1357- (
1358- make_binders ( db, & generics, ctx. lower_ty ( impl_data. self_ty ) ) ,
1359- create_diagnostics ( ctx. diagnostics ) ,
1360- )
1361- }
1362-
13631334pub ( crate ) fn const_param_ty_query ( db : & dyn HirDatabase , def : ConstParamId ) -> Ty {
13641335 const_param_ty_with_diagnostics_query ( db, def) . 0
13651336}
@@ -1397,30 +1368,6 @@ pub(crate) fn const_param_ty_cycle_result(
13971368 TyKind :: Error . intern ( Interner )
13981369}
13991370
1400- pub ( crate ) fn impl_trait_query ( db : & dyn HirDatabase , impl_id : ImplId ) -> Option < Binders < TraitRef > > {
1401- impl_trait_with_diagnostics_query ( db, impl_id) . map ( |it| it. 0 )
1402- }
1403-
1404- pub ( crate ) fn impl_trait_with_diagnostics_query (
1405- db : & dyn HirDatabase ,
1406- impl_id : ImplId ,
1407- ) -> Option < ( Binders < TraitRef > , Diagnostics ) > {
1408- let impl_data = db. impl_signature ( impl_id) ;
1409- let resolver = impl_id. resolver ( db) ;
1410- let mut ctx = TyLoweringContext :: new (
1411- db,
1412- & resolver,
1413- & impl_data. store ,
1414- impl_id. into ( ) ,
1415- LifetimeElisionKind :: AnonymousCreateParameter { report_in_path : true } ,
1416- )
1417- . with_type_param_mode ( ParamLoweringMode :: Variable ) ;
1418- let ( self_ty, binders) = db. impl_self_ty ( impl_id) . into_value_and_skipped_binders ( ) ;
1419- let target_trait = impl_data. target_trait . as_ref ( ) ?;
1420- let trait_ref = Binders :: new ( binders, ctx. lower_trait_ref ( target_trait, self_ty) ?) ;
1421- Some ( ( trait_ref, create_diagnostics ( ctx. diagnostics ) ) )
1422- }
1423-
14241371pub ( crate ) fn return_type_impl_traits (
14251372 db : & dyn HirDatabase ,
14261373 def : hir_def:: FunctionId ,
0 commit comments