@@ -21,7 +21,7 @@ use hir_def::{
21
21
} ;
22
22
23
23
use crate :: {
24
- AliasEq , AliasTy , BoundVar , DebruijnIndex , FnDefId , Interner , ProjectionTy , ProjectionTyExt ,
24
+ AliasEq , AliasTy , BoundVar , DebruijnIndex , Interner , ProjectionTy , ProjectionTyExt ,
25
25
QuantifiedWhereClause , Substitution , TraitRef , TraitRefExt , Ty , TyBuilder , TyExt , TyKind ,
26
26
WhereClause ,
27
27
db:: { HirDatabase , InternedCoroutine } ,
@@ -53,7 +53,7 @@ pub(crate) type Variances = chalk_ir::Variances<Interner>;
53
53
54
54
impl chalk_solve:: RustIrDatabase < Interner > for ChalkContext < ' _ > {
55
55
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 ) )
57
57
}
58
58
fn trait_datum ( & self , trait_id : TraitId ) -> Arc < TraitDatum > {
59
59
self . db . trait_datum ( self . krate , trait_id)
@@ -105,7 +105,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
105
105
& self ,
106
106
fn_def_id : chalk_ir:: FnDefId < Interner > ,
107
107
) -> 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) )
109
109
}
110
110
111
111
fn impls_for_trait (
@@ -447,7 +447,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
447
447
Arc :: new ( rust_ir:: AdtSizeAlign :: from_one_zst ( false ) )
448
448
}
449
449
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 ;
451
451
self . db . type_alias_data ( id) . name . display ( self . db . upcast ( ) , self . edition ( ) ) . to_string ( )
452
452
}
453
453
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 {
583
583
& self ,
584
584
fn_def_id : chalk_ir:: FnDefId < Interner > ,
585
585
) -> 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) )
587
587
}
588
588
589
589
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 )
591
591
}
592
592
}
593
593
@@ -602,10 +602,9 @@ pub(crate) fn program_clauses_for_chalk_env_query(
602
602
603
603
pub ( crate ) fn associated_ty_data_query (
604
604
db : & dyn HirDatabase ,
605
- id : AssocTypeId ,
605
+ type_alias : TypeAliasId ,
606
606
) -> 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) ;
609
608
let trait_ = match type_alias. lookup ( db. upcast ( ) ) . container {
610
609
ItemContainerId :: TraitId ( t) => t,
611
610
_ => panic ! ( "associated type not in trait" ) ,
@@ -656,7 +655,7 @@ pub(crate) fn associated_ty_data_query(
656
655
let bound_data = rust_ir:: AssociatedTyDatumBound { bounds, where_clauses : vec ! [ ] } ;
657
656
let datum = AssociatedTyDatum {
658
657
trait_id : to_chalk_trait_id ( trait_) ,
659
- id,
658
+ id : to_assoc_type_id ( type_alias ) ,
660
659
name : type_alias,
661
660
binders : make_binders ( db, & generic_params, bound_data) ,
662
661
} ;
@@ -923,8 +922,10 @@ fn type_alias_associated_ty_value(
923
922
Arc :: new ( value)
924
923
}
925
924
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 > {
928
929
let generic_def = GenericDefId :: from_callable ( db. upcast ( ) , callable_def) ;
929
930
let generic_params = generics ( db. upcast ( ) , generic_def) ;
930
931
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
943
944
where_clauses,
944
945
} ;
945
946
let datum = FnDefDatum {
946
- id : fn_def_id ,
947
+ id : callable_def . to_chalk ( db ) ,
947
948
sig : chalk_ir:: FnSig {
948
949
abi : sig. abi ,
949
950
safety : chalk_ir:: Safety :: Safe ,
@@ -954,8 +955,10 @@ pub(crate) fn fn_def_datum_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Ar
954
955
Arc :: new ( datum)
955
956
}
956
957
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 {
959
962
Variances :: from_iter (
960
963
Interner ,
961
964
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) ->
971
974
)
972
975
}
973
976
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 {
978
978
Variances :: from_iter (
979
979
Interner ,
980
980
db. variances_of ( adt_id. into ( ) ) . as_deref ( ) . unwrap_or_default ( ) . iter ( ) . map ( |v| match v {
0 commit comments