@@ -25,7 +25,7 @@ use chalk_ir::{
25
25
use either:: Either ;
26
26
use hir_def:: {
27
27
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 ,
29
29
TypeOrConstParamId , UnionId , VariantId ,
30
30
builtin_type:: BuiltinType ,
31
31
expr_store:: { ExpressionStore , path:: Path } ,
@@ -34,8 +34,8 @@ use hir_def::{
34
34
resolver:: { HasResolver , LifetimeNs , Resolver , TypeNs } ,
35
35
signatures:: { FunctionSignature , TraitFlags } ,
36
36
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 ,
39
39
} ,
40
40
} ;
41
41
use hir_expand:: name:: Name ;
@@ -59,6 +59,10 @@ use crate::{
59
59
} ,
60
60
make_binders,
61
61
mapping:: { from_chalk_trait_id, lt_to_placeholder_idx} ,
62
+ next_solver:: {
63
+ DbInterner ,
64
+ mapping:: { ChalkToNextSolver , NextSolverToChalk } ,
65
+ } ,
62
66
static_lifetime, to_chalk_trait_id, to_placeholder_idx,
63
67
utils:: all_super_trait_refs,
64
68
variable_kinds_from_iter,
@@ -565,14 +569,6 @@ impl<'a> TyLoweringContext<'a> {
565
569
Some ( ( ctx. lower_trait_ref_from_resolved_path ( resolved, explicit_self_ty, false ) , ctx) )
566
570
}
567
571
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
-
576
572
/// When lowering predicates from parents (impl, traits) for children defs (fns, consts, types), `generics` should
577
573
/// contain the `Generics` for the **child**, while `predicate_owner` should contain the `GenericDefId` of the
578
574
/// **parent**. This is important so we generate the correct bound var/placeholder.
@@ -851,21 +847,21 @@ fn named_associated_type_shorthand_candidates<R>(
851
847
} )
852
848
} ;
853
849
850
+ let interner = DbInterner :: new_with ( db, None , None ) ;
854
851
match res {
855
852
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) ?;
859
854
860
855
let impl_id_as_generic_def: GenericDefId = impl_id. into ( ) ;
861
856
if impl_id_as_generic_def != def {
862
857
let subst = TyBuilder :: subst_for_def ( db, impl_id, None )
863
858
. fill_with_bound_vars ( DebruijnIndex :: INNERMOST , 0 )
864
859
. 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) ;
866
862
search ( trait_ref)
867
863
} else {
868
- search ( trait_ref)
864
+ search ( trait_ref. skip_binder ( ) . to_chalk ( interner ) )
869
865
}
870
866
}
871
867
TypeNs :: GenericParam ( param_id) => {
@@ -1335,31 +1331,6 @@ impl ValueTyDefId {
1335
1331
}
1336
1332
}
1337
1333
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
-
1363
1334
pub ( crate ) fn const_param_ty_query ( db : & dyn HirDatabase , def : ConstParamId ) -> Ty {
1364
1335
const_param_ty_with_diagnostics_query ( db, def) . 0
1365
1336
}
@@ -1397,30 +1368,6 @@ pub(crate) fn const_param_ty_cycle_result(
1397
1368
TyKind :: Error . intern ( Interner )
1398
1369
}
1399
1370
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
-
1424
1371
pub ( crate ) fn return_type_impl_traits (
1425
1372
db : & dyn HirDatabase ,
1426
1373
def : hir_def:: FunctionId ,
0 commit comments