@@ -21,7 +21,7 @@ use hir_def::{
2121} ;
2222
2323use crate :: {
24- AliasEq , AliasTy , BoundVar , DebruijnIndex , FnDefId , Interner , ProjectionTy , ProjectionTyExt ,
24+ AliasEq , AliasTy , BoundVar , DebruijnIndex , Interner , ProjectionTy , ProjectionTyExt ,
2525 QuantifiedWhereClause , Substitution , TraitRef , TraitRefExt , Ty , TyBuilder , TyExt , TyKind ,
2626 WhereClause ,
2727 db:: { HirDatabase , InternedCoroutine } ,
@@ -53,7 +53,7 @@ pub(crate) type Variances = chalk_ir::Variances<Interner>;
5353
5454impl chalk_solve:: RustIrDatabase < Interner > for ChalkContext < ' _ > {
5555 fn associated_ty_data ( & self , id : AssocTypeId ) -> Arc < AssociatedTyDatum > {
56- self . db . associated_ty_data ( id )
56+ self . db . associated_ty_data ( from_assoc_type_id ( id ) )
5757 }
5858 fn trait_datum ( & self , trait_id : TraitId ) -> Arc < TraitDatum > {
5959 self . db . trait_datum ( self . krate , trait_id)
@@ -105,7 +105,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
105105 & self ,
106106 fn_def_id : chalk_ir:: FnDefId < Interner > ,
107107 ) -> Arc < rust_ir:: FnDefDatum < Interner > > {
108- self . db . fn_def_datum ( fn_def_id)
108+ self . db . fn_def_datum ( from_chalk ( self . db , fn_def_id) )
109109 }
110110
111111 fn impls_for_trait (
@@ -447,7 +447,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
447447 Arc :: new ( rust_ir:: AdtSizeAlign :: from_one_zst ( false ) )
448448 }
449449 fn assoc_type_name ( & self , assoc_ty_id : chalk_ir:: AssocTypeId < Interner > ) -> String {
450- let id = self . db . associated_ty_data ( assoc_ty_id) . name ;
450+ let id = self . db . associated_ty_data ( from_assoc_type_id ( assoc_ty_id) ) . name ;
451451 self . db . type_alias_data ( id) . name . display ( self . db . upcast ( ) , self . edition ( ) ) . to_string ( )
452452 }
453453 fn opaque_type_name ( & self , opaque_ty_id : chalk_ir:: OpaqueTyId < Interner > ) -> String {
@@ -583,11 +583,11 @@ impl chalk_ir::UnificationDatabase<Interner> for &dyn HirDatabase {
583583 & self ,
584584 fn_def_id : chalk_ir:: FnDefId < Interner > ,
585585 ) -> chalk_ir:: Variances < Interner > {
586- HirDatabase :: fn_def_variance ( * self , fn_def_id)
586+ HirDatabase :: fn_def_variance ( * self , from_chalk ( * self , fn_def_id) )
587587 }
588588
589589 fn adt_variance ( & self , adt_id : chalk_ir:: AdtId < Interner > ) -> chalk_ir:: Variances < Interner > {
590- HirDatabase :: adt_variance ( * self , adt_id)
590+ HirDatabase :: adt_variance ( * self , adt_id. 0 )
591591 }
592592}
593593
@@ -602,10 +602,9 @@ pub(crate) fn program_clauses_for_chalk_env_query(
602602
603603pub ( crate ) fn associated_ty_data_query (
604604 db : & dyn HirDatabase ,
605- id : AssocTypeId ,
605+ type_alias : TypeAliasId ,
606606) -> Arc < AssociatedTyDatum > {
607- debug ! ( "associated_ty_data {:?}" , id) ;
608- let type_alias: TypeAliasId = from_assoc_type_id ( id) ;
607+ debug ! ( "associated_ty_data {:?}" , type_alias) ;
609608 let trait_ = match type_alias. lookup ( db. upcast ( ) ) . container {
610609 ItemContainerId :: TraitId ( t) => t,
611610 _ => panic ! ( "associated type not in trait" ) ,
@@ -656,7 +655,7 @@ pub(crate) fn associated_ty_data_query(
656655 let bound_data = rust_ir:: AssociatedTyDatumBound { bounds, where_clauses : vec ! [ ] } ;
657656 let datum = AssociatedTyDatum {
658657 trait_id : to_chalk_trait_id ( trait_) ,
659- id,
658+ id : to_assoc_type_id ( type_alias ) ,
660659 name : type_alias,
661660 binders : make_binders ( db, & generic_params, bound_data) ,
662661 } ;
@@ -923,8 +922,10 @@ fn type_alias_associated_ty_value(
923922 Arc :: new ( value)
924923}
925924
926- pub ( crate ) fn fn_def_datum_query ( db : & dyn HirDatabase , fn_def_id : FnDefId ) -> Arc < FnDefDatum > {
927- let callable_def: CallableDefId = from_chalk ( db, fn_def_id) ;
925+ pub ( crate ) fn fn_def_datum_query (
926+ db : & dyn HirDatabase ,
927+ callable_def : CallableDefId ,
928+ ) -> Arc < FnDefDatum > {
928929 let generic_def = GenericDefId :: from_callable ( db. upcast ( ) , callable_def) ;
929930 let generic_params = generics ( db. upcast ( ) , generic_def) ;
930931 let ( sig, binders) = db. callable_item_signature ( callable_def) . into_value_and_skipped_binders ( ) ;
@@ -943,7 +944,7 @@ pub(crate) fn fn_def_datum_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Ar
943944 where_clauses,
944945 } ;
945946 let datum = FnDefDatum {
946- id : fn_def_id ,
947+ id : callable_def . to_chalk ( db ) ,
947948 sig : chalk_ir:: FnSig {
948949 abi : sig. abi ,
949950 safety : chalk_ir:: Safety :: Safe ,
@@ -954,8 +955,10 @@ pub(crate) fn fn_def_datum_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Ar
954955 Arc :: new ( datum)
955956}
956957
957- pub ( crate ) fn fn_def_variance_query ( db : & dyn HirDatabase , fn_def_id : FnDefId ) -> Variances {
958- let callable_def: CallableDefId = from_chalk ( db, fn_def_id) ;
958+ pub ( crate ) fn fn_def_variance_query (
959+ db : & dyn HirDatabase ,
960+ callable_def : CallableDefId ,
961+ ) -> Variances {
959962 Variances :: from_iter (
960963 Interner ,
961964 db. variances_of ( GenericDefId :: from_callable ( db. upcast ( ) , callable_def) )
@@ -971,10 +974,7 @@ pub(crate) fn fn_def_variance_query(db: &dyn HirDatabase, fn_def_id: FnDefId) ->
971974 )
972975}
973976
974- pub ( crate ) fn adt_variance_query (
975- db : & dyn HirDatabase ,
976- chalk_ir:: AdtId ( adt_id) : AdtId ,
977- ) -> Variances {
977+ pub ( crate ) fn adt_variance_query ( db : & dyn HirDatabase , adt_id : hir_def:: AdtId ) -> Variances {
978978 Variances :: from_iter (
979979 Interner ,
980980 db. variances_of ( adt_id. into ( ) ) . as_deref ( ) . unwrap_or_default ( ) . iter ( ) . map ( |v| match v {
0 commit comments