@@ -8,6 +8,7 @@ use chalk_ir::{
8
8
TypeKindId , TypeName , UniverseIndex ,
9
9
} ;
10
10
use chalk_rust_ir:: { AssociatedTyDatum , AssociatedTyValue , ImplDatum , StructDatum , TraitDatum } ;
11
+ use ra_db:: CrateId ;
11
12
12
13
use hir_def:: {
13
14
lang_item:: LangItemTarget , AstItemDef , ContainerId , GenericDefId , Lookup , TraitId , TypeAliasId ,
@@ -21,7 +22,7 @@ use crate::{
21
22
db:: HirDatabase ,
22
23
ty:: display:: HirDisplay ,
23
24
ty:: { ApplicationTy , GenericPredicate , ProjectionTy , Substs , TraitRef , Ty , TypeCtor , TypeWalk } ,
24
- Crate , ImplBlock , TypeAlias ,
25
+ ImplBlock , TypeAlias ,
25
26
} ;
26
27
27
28
/// This represents a trait whose name we could not resolve.
@@ -448,7 +449,7 @@ where
448
449
let trait_: TraitId = from_chalk ( self . db , trait_id) ;
449
450
let mut result: Vec < _ > = self
450
451
. db
451
- . impls_for_trait ( self . krate . crate_id , trait_. into ( ) )
452
+ . impls_for_trait ( self . krate , trait_. into ( ) )
452
453
. iter ( )
453
454
. copied ( )
454
455
. map ( Impl :: ImplBlock )
@@ -487,7 +488,7 @@ where
487
488
& self ,
488
489
id : chalk_rust_ir:: AssociatedTyValueId ,
489
490
) -> Arc < AssociatedTyValue < ChalkIr > > {
490
- self . db . associated_ty_value ( self . krate , id)
491
+ self . db . associated_ty_value ( self . krate . into ( ) , id)
491
492
}
492
493
fn custom_clauses ( & self ) -> Vec < chalk_ir:: ProgramClause < ChalkIr > > {
493
494
vec ! [ ]
@@ -528,7 +529,7 @@ pub(crate) fn associated_ty_data_query(
528
529
529
530
pub ( crate ) fn trait_datum_query (
530
531
db : & impl HirDatabase ,
531
- krate : Crate ,
532
+ krate : CrateId ,
532
533
trait_id : chalk_ir:: TraitId ,
533
534
) -> Arc < TraitDatum < ChalkIr > > {
534
535
debug ! ( "trait_datum {:?}" , trait_id) ;
@@ -557,7 +558,7 @@ pub(crate) fn trait_datum_query(
557
558
let bound_vars = Substs :: bound_vars ( & generic_params) ;
558
559
let flags = chalk_rust_ir:: TraitFlags {
559
560
auto : trait_data. auto ,
560
- upstream : trait_. module ( db) . krate != krate. crate_id ,
561
+ upstream : trait_. module ( db) . krate != krate,
561
562
non_enumerable : true ,
562
563
coinductive : false , // only relevant for Chalk testing
563
564
// FIXME set these flags correctly
@@ -579,7 +580,7 @@ pub(crate) fn trait_datum_query(
579
580
580
581
pub ( crate ) fn struct_datum_query (
581
582
db : & impl HirDatabase ,
582
- krate : Crate ,
583
+ krate : CrateId ,
583
584
struct_id : chalk_ir:: StructId ,
584
585
) -> Arc < StructDatum < ChalkIr > > {
585
586
debug ! ( "struct_datum {:?}" , struct_id) ;
@@ -611,7 +612,7 @@ pub(crate) fn struct_datum_query(
611
612
612
613
pub ( crate ) fn impl_datum_query (
613
614
db : & impl HirDatabase ,
614
- krate : Crate ,
615
+ krate : CrateId ,
615
616
impl_id : ImplId ,
616
617
) -> Arc < ImplDatum < ChalkIr > > {
617
618
let _p = ra_prof:: profile ( "impl_datum" ) ;
@@ -626,15 +627,15 @@ pub(crate) fn impl_datum_query(
626
627
627
628
fn impl_block_datum (
628
629
db : & impl HirDatabase ,
629
- krate : Crate ,
630
+ krate : CrateId ,
630
631
impl_id : ImplId ,
631
632
impl_block : ImplBlock ,
632
633
) -> Option < Arc < ImplDatum < ChalkIr > > > {
633
634
let generic_params = db. generic_params ( impl_block. id . into ( ) ) ;
634
635
let bound_vars = Substs :: bound_vars ( & generic_params) ;
635
636
let trait_ref = impl_block. target_trait_ref ( db) ?. subst ( & bound_vars) ;
636
637
let trait_ = trait_ref. trait_ ;
637
- let impl_type = if impl_block. krate ( db) == krate {
638
+ let impl_type = if impl_block. krate ( db) . crate_id == krate {
638
639
chalk_rust_ir:: ImplType :: Local
639
640
} else {
640
641
chalk_rust_ir:: ImplType :: External
@@ -698,7 +699,7 @@ fn invalid_impl_datum() -> Arc<ImplDatum<ChalkIr>> {
698
699
699
700
fn closure_fn_trait_impl_datum (
700
701
db : & impl HirDatabase ,
701
- krate : Crate ,
702
+ krate : CrateId ,
702
703
data : super :: ClosureFnTraitImplData ,
703
704
) -> Option < Arc < ImplDatum < ChalkIr > > > {
704
705
// for some closure |X, Y| -> Z:
@@ -755,7 +756,7 @@ fn closure_fn_trait_impl_datum(
755
756
756
757
pub ( crate ) fn associated_ty_value_query (
757
758
db : & impl HirDatabase ,
758
- krate : Crate ,
759
+ krate : CrateId ,
759
760
id : chalk_rust_ir:: AssociatedTyValueId ,
760
761
) -> Arc < chalk_rust_ir:: AssociatedTyValue < ChalkIr > > {
761
762
let data: AssocTyValue = from_chalk ( db, id) ;
@@ -771,7 +772,7 @@ pub(crate) fn associated_ty_value_query(
771
772
772
773
fn type_alias_associated_ty_value (
773
774
db : & impl HirDatabase ,
774
- _krate : Crate ,
775
+ _krate : CrateId ,
775
776
type_alias : TypeAlias ,
776
777
) -> Arc < AssociatedTyValue < ChalkIr > > {
777
778
let impl_block = type_alias. impl_block ( db) . expect ( "assoc ty value should be in impl" ) ;
@@ -798,7 +799,7 @@ fn type_alias_associated_ty_value(
798
799
799
800
fn closure_fn_trait_output_assoc_ty_value (
800
801
db : & impl HirDatabase ,
801
- krate : Crate ,
802
+ krate : CrateId ,
802
803
data : super :: ClosureFnTraitImplData ,
803
804
) -> Arc < AssociatedTyValue < ChalkIr > > {
804
805
let impl_id = Impl :: ClosureFnTraitImpl ( data. clone ( ) ) . to_chalk ( db) ;
@@ -831,8 +832,12 @@ fn closure_fn_trait_output_assoc_ty_value(
831
832
Arc :: new ( value)
832
833
}
833
834
834
- fn get_fn_trait ( db : & impl HirDatabase , krate : Crate , fn_trait : super :: FnTrait ) -> Option < TraitId > {
835
- let target = db. lang_item ( krate. crate_id , fn_trait. lang_item_name ( ) . into ( ) ) ?;
835
+ fn get_fn_trait (
836
+ db : & impl HirDatabase ,
837
+ krate : CrateId ,
838
+ fn_trait : super :: FnTrait ,
839
+ ) -> Option < TraitId > {
840
+ let target = db. lang_item ( krate, fn_trait. lang_item_name ( ) . into ( ) ) ?;
836
841
match target {
837
842
LangItemTarget :: TraitId ( t) => Some ( t) ,
838
843
_ => None ,
0 commit comments