diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-30 10:14:18 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-30 10:14:18 +0000 |
commit | f996b6019bd2f388bd9994ea83f25487eb111560 (patch) | |
tree | 4662b1c76bed5e830c1dae9ee5dbf47520f41e1e /crates/ra_hir/src/ty | |
parent | 8046f5b24a316a50e109fe484cde4c128293fa97 (diff) | |
parent | c9cd6aa370667783292de3bc580e0503a409e453 (diff) |
Merge #2126
2126: Move ids to hir_def crate r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 38 |
2 files changed, 13 insertions, 37 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index ad2ab560d..50583a142 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -5,13 +5,13 @@ | |||
5 | use std::sync::Arc; | 5 | use std::sync::Arc; |
6 | 6 | ||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use hir_def::CrateModuleId; | ||
8 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
9 | 10 | ||
10 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; | 11 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; |
11 | use crate::{ | 12 | use crate::{ |
12 | db::HirDatabase, | 13 | db::HirDatabase, |
13 | impl_block::{ImplBlock, ImplId}, | 14 | impl_block::{ImplBlock, ImplId}, |
14 | nameres::CrateModuleId, | ||
15 | resolve::Resolver, | 15 | resolve::Resolver, |
16 | ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, | 16 | ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, |
17 | ty::{Ty, TypeCtor}, | 17 | ty::{Ty, TypeCtor}, |
@@ -50,7 +50,7 @@ impl CrateImplBlocks { | |||
50 | let fingerprint = TyFingerprint::for_impl(ty); | 50 | let fingerprint = TyFingerprint::for_impl(ty); |
51 | fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map( | 51 | fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map( |
52 | move |(module_id, impl_id)| { | 52 | move |(module_id, impl_id)| { |
53 | let module = Module { krate: self.krate, module_id: *module_id }; | 53 | let module = Module::new(self.krate, *module_id); |
54 | ImplBlock::from_id(module, *impl_id) | 54 | ImplBlock::from_id(module, *impl_id) |
55 | }, | 55 | }, |
56 | ) | 56 | ) |
@@ -62,7 +62,7 @@ impl CrateImplBlocks { | |||
62 | ) -> impl Iterator<Item = ImplBlock> + 'a { | 62 | ) -> impl Iterator<Item = ImplBlock> + 'a { |
63 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( | 63 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( |
64 | move |(module_id, impl_id)| { | 64 | move |(module_id, impl_id)| { |
65 | let module = Module { krate: self.krate, module_id: *module_id }; | 65 | let module = Module::new(self.krate, *module_id); |
66 | ImplBlock::from_id(module, *impl_id) | 66 | ImplBlock::from_id(module, *impl_id) |
67 | }, | 67 | }, |
68 | ) | 68 | ) |
@@ -71,7 +71,7 @@ impl CrateImplBlocks { | |||
71 | pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplBlock> + 'a { | 71 | pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplBlock> + 'a { |
72 | self.impls.values().chain(self.impls_by_trait.values()).flat_map(|i| i.iter()).map( | 72 | self.impls.values().chain(self.impls_by_trait.values()).flat_map(|i| i.iter()).map( |
73 | move |(module_id, impl_id)| { | 73 | move |(module_id, impl_id)| { |
74 | let module = Module { krate: self.krate, module_id: *module_id }; | 74 | let module = Module::new(self.krate, *module_id); |
75 | ImplBlock::from_id(module, *impl_id) | 75 | ImplBlock::from_id(module, *impl_id) |
76 | }, | 76 | }, |
77 | ) | 77 | ) |
@@ -90,14 +90,14 @@ impl CrateImplBlocks { | |||
90 | self.impls_by_trait | 90 | self.impls_by_trait |
91 | .entry(tr.trait_) | 91 | .entry(tr.trait_) |
92 | .or_insert_with(Vec::new) | 92 | .or_insert_with(Vec::new) |
93 | .push((module.module_id, impl_id)); | 93 | .push((module.id.module_id, impl_id)); |
94 | } | 94 | } |
95 | } else { | 95 | } else { |
96 | if let Some(target_ty_fp) = TyFingerprint::for_impl(&target_ty) { | 96 | if let Some(target_ty_fp) = TyFingerprint::for_impl(&target_ty) { |
97 | self.impls | 97 | self.impls |
98 | .entry(target_ty_fp) | 98 | .entry(target_ty_fp) |
99 | .or_insert_with(Vec::new) | 99 | .or_insert_with(Vec::new) |
100 | .push((module.module_id, impl_id)); | 100 | .push((module.id.module_id, impl_id)); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index e18c28cf6..ab66515be 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -162,11 +162,11 @@ impl ToChalk for Trait { | |||
162 | type Chalk = chalk_ir::TraitId; | 162 | type Chalk = chalk_ir::TraitId; |
163 | 163 | ||
164 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TraitId { | 164 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TraitId { |
165 | self.id.into() | 165 | chalk_ir::TraitId(id_to_chalk(self.id)) |
166 | } | 166 | } |
167 | 167 | ||
168 | fn from_chalk(_db: &impl HirDatabase, trait_id: chalk_ir::TraitId) -> Trait { | 168 | fn from_chalk(_db: &impl HirDatabase, trait_id: chalk_ir::TraitId) -> Trait { |
169 | Trait { id: trait_id.into() } | 169 | Trait { id: id_from_chalk(trait_id.0) } |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -198,11 +198,11 @@ impl ToChalk for TypeAlias { | |||
198 | type Chalk = chalk_ir::TypeId; | 198 | type Chalk = chalk_ir::TypeId; |
199 | 199 | ||
200 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { | 200 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { |
201 | self.id.into() | 201 | chalk_ir::TypeId(id_to_chalk(self.id)) |
202 | } | 202 | } |
203 | 203 | ||
204 | fn from_chalk(_db: &impl HirDatabase, impl_id: chalk_ir::TypeId) -> TypeAlias { | 204 | fn from_chalk(_db: &impl HirDatabase, type_alias_id: chalk_ir::TypeId) -> TypeAlias { |
205 | TypeAlias { id: impl_id.into() } | 205 | TypeAlias { id: id_from_chalk(type_alias_id.0) } |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
@@ -537,7 +537,7 @@ pub(crate) fn trait_datum_query( | |||
537 | let trait_ref = trait_.trait_ref(db).subst(&bound_vars).to_chalk(db); | 537 | let trait_ref = trait_.trait_ref(db).subst(&bound_vars).to_chalk(db); |
538 | let flags = chalk_rust_ir::TraitFlags { | 538 | let flags = chalk_rust_ir::TraitFlags { |
539 | auto: trait_.is_auto(db), | 539 | auto: trait_.is_auto(db), |
540 | upstream: trait_.module(db).krate(db) != Some(krate), | 540 | upstream: trait_.module(db).krate() != krate, |
541 | non_enumerable: true, | 541 | non_enumerable: true, |
542 | // FIXME set these flags correctly | 542 | // FIXME set these flags correctly |
543 | marker: false, | 543 | marker: false, |
@@ -625,7 +625,7 @@ fn impl_block_datum( | |||
625 | .target_trait_ref(db) | 625 | .target_trait_ref(db) |
626 | .expect("FIXME handle unresolved impl block trait ref") | 626 | .expect("FIXME handle unresolved impl block trait ref") |
627 | .subst(&bound_vars); | 627 | .subst(&bound_vars); |
628 | let impl_type = if impl_block.module().krate(db) == Some(krate) { | 628 | let impl_type = if impl_block.module().krate() == krate { |
629 | chalk_rust_ir::ImplType::Local | 629 | chalk_rust_ir::ImplType::Local |
630 | } else { | 630 | } else { |
631 | chalk_rust_ir::ImplType::External | 631 | chalk_rust_ir::ImplType::External |
@@ -775,30 +775,6 @@ fn id_to_chalk<T: InternKey>(salsa_id: T) -> chalk_ir::RawId { | |||
775 | chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } | 775 | chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } |
776 | } | 776 | } |
777 | 777 | ||
778 | impl From<chalk_ir::TraitId> for crate::ids::TraitId { | ||
779 | fn from(trait_id: chalk_ir::TraitId) -> Self { | ||
780 | id_from_chalk(trait_id.0) | ||
781 | } | ||
782 | } | ||
783 | |||
784 | impl From<crate::ids::TraitId> for chalk_ir::TraitId { | ||
785 | fn from(trait_id: crate::ids::TraitId) -> Self { | ||
786 | chalk_ir::TraitId(id_to_chalk(trait_id)) | ||
787 | } | ||
788 | } | ||
789 | |||
790 | impl From<chalk_ir::TypeId> for crate::ids::TypeAliasId { | ||
791 | fn from(type_id: chalk_ir::TypeId) -> Self { | ||
792 | id_from_chalk(type_id.0) | ||
793 | } | ||
794 | } | ||
795 | |||
796 | impl From<crate::ids::TypeAliasId> for chalk_ir::TypeId { | ||
797 | fn from(type_id: crate::ids::TypeAliasId) -> Self { | ||
798 | chalk_ir::TypeId(id_to_chalk(type_id)) | ||
799 | } | ||
800 | } | ||
801 | |||
802 | impl From<chalk_ir::StructId> for crate::ids::TypeCtorId { | 778 | impl From<chalk_ir::StructId> for crate::ids::TypeCtorId { |
803 | fn from(struct_id: chalk_ir::StructId) -> Self { | 779 | fn from(struct_id: chalk_ir::StructId) -> Self { |
804 | id_from_chalk(struct_id.0) | 780 | id_from_chalk(struct_id.0) |