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