diff options
author | Jonas Schievink <[email protected]> | 2021-01-22 17:09:55 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-01-22 17:09:55 +0000 |
commit | 3de8f57c51192fa8e57713a3580c2bcc6907a194 (patch) | |
tree | f062bb33b2cfe9983605d6957eb56ddc21af2e93 /crates/hir_ty | |
parent | e73cc8b4abed6e6f5d801d0032070fa9fc662ec3 (diff) |
Make `ModuleId`'s `krate` field private
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/display.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 14 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/test_db.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/tests.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 4 |
7 files changed, 17 insertions, 15 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index d2f1b4014..38a043c48 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -617,7 +617,7 @@ impl HirDisplay for FnSig { | |||
617 | } | 617 | } |
618 | 618 | ||
619 | fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = TraitId> { | 619 | fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = TraitId> { |
620 | let krate = trait_.lookup(db).container.module(db).krate; | 620 | let krate = trait_.lookup(db).container.module(db).krate(); |
621 | let fn_traits = [ | 621 | let fn_traits = [ |
622 | db.lang_item(krate, "fn".into()), | 622 | db.lang_item(krate, "fn".into()), |
623 | db.lang_item(krate, "fn_mut".into()), | 623 | db.lang_item(krate, "fn_mut".into()), |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index e00c7e176..d47f975d2 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -211,19 +211,21 @@ impl TypeCtor { | |||
211 | | TypeCtor::Tuple { .. } => None, | 211 | | TypeCtor::Tuple { .. } => None, |
212 | // Closure's krate is irrelevant for coherence I would think? | 212 | // Closure's krate is irrelevant for coherence I would think? |
213 | TypeCtor::Closure { .. } => None, | 213 | TypeCtor::Closure { .. } => None, |
214 | TypeCtor::Adt(adt) => Some(adt.module(db.upcast()).krate), | 214 | TypeCtor::Adt(adt) => Some(adt.module(db.upcast()).krate()), |
215 | TypeCtor::FnDef(callable) => Some(callable.krate(db)), | 215 | TypeCtor::FnDef(callable) => Some(callable.krate(db)), |
216 | TypeCtor::AssociatedType(type_alias) => { | 216 | TypeCtor::AssociatedType(type_alias) => { |
217 | Some(type_alias.lookup(db.upcast()).module(db.upcast()).krate) | 217 | Some(type_alias.lookup(db.upcast()).module(db.upcast()).krate()) |
218 | } | 218 | } |
219 | TypeCtor::ForeignType(type_alias) => { | 219 | TypeCtor::ForeignType(type_alias) => { |
220 | Some(type_alias.lookup(db.upcast()).module(db.upcast()).krate) | 220 | Some(type_alias.lookup(db.upcast()).module(db.upcast()).krate()) |
221 | } | 221 | } |
222 | TypeCtor::OpaqueType(opaque_ty_id) => match opaque_ty_id { | 222 | TypeCtor::OpaqueType(opaque_ty_id) => match opaque_ty_id { |
223 | OpaqueTyId::ReturnTypeImplTrait(func, _) => { | 223 | OpaqueTyId::ReturnTypeImplTrait(func, _) => { |
224 | Some(func.lookup(db.upcast()).module(db.upcast()).krate) | 224 | Some(func.lookup(db.upcast()).module(db.upcast()).krate()) |
225 | } | ||
226 | OpaqueTyId::AsyncBlockTypeImplTrait(def, _) => { | ||
227 | Some(def.module(db.upcast()).krate()) | ||
225 | } | 228 | } |
226 | OpaqueTyId::AsyncBlockTypeImplTrait(def, _) => Some(def.module(db.upcast()).krate), | ||
227 | }, | 229 | }, |
228 | } | 230 | } |
229 | } | 231 | } |
@@ -870,7 +872,7 @@ impl Ty { | |||
870 | Ty::Apply(ApplicationTy { ctor: TypeCtor::OpaqueType(opaque_ty_id), .. }) => { | 872 | Ty::Apply(ApplicationTy { ctor: TypeCtor::OpaqueType(opaque_ty_id), .. }) => { |
871 | match opaque_ty_id { | 873 | match opaque_ty_id { |
872 | OpaqueTyId::AsyncBlockTypeImplTrait(def, _expr) => { | 874 | OpaqueTyId::AsyncBlockTypeImplTrait(def, _expr) => { |
873 | let krate = def.module(db.upcast()).krate; | 875 | let krate = def.module(db.upcast()).krate(); |
874 | if let Some(future_trait) = db | 876 | if let Some(future_trait) = db |
875 | .lang_item(krate, "future_trait".into()) | 877 | .lang_item(krate, "future_trait".into()) |
876 | .and_then(|item| item.as_trait()) | 878 | .and_then(|item| item.as_trait()) |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 7a734c8b9..dfb573ff3 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -1147,7 +1147,7 @@ impl CallableDefId { | |||
1147 | CallableDefId::StructId(s) => s.lookup(db).container.module(db), | 1147 | CallableDefId::StructId(s) => s.lookup(db).container.module(db), |
1148 | CallableDefId::EnumVariantId(e) => e.parent.lookup(db).container.module(db), | 1148 | CallableDefId::EnumVariantId(e) => e.parent.lookup(db).container.module(db), |
1149 | } | 1149 | } |
1150 | .krate | 1150 | .krate() |
1151 | } | 1151 | } |
1152 | } | 1152 | } |
1153 | 1153 | ||
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index f06aeeb42..a302456b0 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -248,12 +248,12 @@ impl Ty { | |||
248 | let lang_item_targets = match self { | 248 | let lang_item_targets = match self { |
249 | Ty::Apply(a_ty) => match a_ty.ctor { | 249 | Ty::Apply(a_ty) => match a_ty.ctor { |
250 | TypeCtor::Adt(def_id) => { | 250 | TypeCtor::Adt(def_id) => { |
251 | return Some(std::iter::once(def_id.module(db.upcast()).krate).collect()) | 251 | return Some(std::iter::once(def_id.module(db.upcast()).krate()).collect()) |
252 | } | 252 | } |
253 | TypeCtor::ForeignType(type_alias_id) => { | 253 | TypeCtor::ForeignType(type_alias_id) => { |
254 | return Some( | 254 | return Some( |
255 | std::iter::once( | 255 | std::iter::once( |
256 | type_alias_id.lookup(db.upcast()).module(db.upcast()).krate, | 256 | type_alias_id.lookup(db.upcast()).module(db.upcast()).krate(), |
257 | ) | 257 | ) |
258 | .collect(), | 258 | .collect(), |
259 | ) | 259 | ) |
@@ -280,7 +280,7 @@ impl Ty { | |||
280 | LangItemTarget::ImplDefId(it) => Some(it), | 280 | LangItemTarget::ImplDefId(it) => Some(it), |
281 | _ => None, | 281 | _ => None, |
282 | }) | 282 | }) |
283 | .map(|it| it.lookup(db.upcast()).container.module(db.upcast()).krate) | 283 | .map(|it| it.lookup(db.upcast()).container.module(db.upcast()).krate()) |
284 | .collect(); | 284 | .collect(); |
285 | Some(res) | 285 | Some(res) |
286 | } | 286 | } |
diff --git a/crates/hir_ty/src/test_db.rs b/crates/hir_ty/src/test_db.rs index 3bbcbc242..09696fcf4 100644 --- a/crates/hir_ty/src/test_db.rs +++ b/crates/hir_ty/src/test_db.rs | |||
@@ -83,7 +83,7 @@ impl TestDB { | |||
83 | let crate_def_map = self.crate_def_map(krate); | 83 | let crate_def_map = self.crate_def_map(krate); |
84 | for (local_id, data) in crate_def_map.modules() { | 84 | for (local_id, data) in crate_def_map.modules() { |
85 | if data.origin.file_id() == Some(file_id) { | 85 | if data.origin.file_id() == Some(file_id) { |
86 | return ModuleId { krate, local_id }; | 86 | return ModuleId::top_level(krate, local_id); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index 25ee664d6..7386a4e7b 100644 --- a/crates/hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs | |||
@@ -343,7 +343,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() { | |||
343 | { | 343 | { |
344 | let events = db.log_executed(|| { | 344 | let events = db.log_executed(|| { |
345 | let module = db.module_for_file(pos.file_id); | 345 | let module = db.module_for_file(pos.file_id); |
346 | let crate_def_map = db.crate_def_map(module.krate); | 346 | let crate_def_map = module.def_map(&db); |
347 | visit_module(&db, &crate_def_map, module.local_id, &mut |def| { | 347 | visit_module(&db, &crate_def_map, module.local_id, &mut |def| { |
348 | db.infer(def); | 348 | db.infer(def); |
349 | }); | 349 | }); |
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 2196af677..cfb756158 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -426,7 +426,7 @@ pub(crate) fn trait_datum_query( | |||
426 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 426 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
427 | let flags = rust_ir::TraitFlags { | 427 | let flags = rust_ir::TraitFlags { |
428 | auto: trait_data.auto, | 428 | auto: trait_data.auto, |
429 | upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate, | 429 | upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate() != krate, |
430 | non_enumerable: true, | 430 | non_enumerable: true, |
431 | coinductive: false, // only relevant for Chalk testing | 431 | coinductive: false, // only relevant for Chalk testing |
432 | // FIXME: set these flags correctly | 432 | // FIXME: set these flags correctly |
@@ -549,7 +549,7 @@ fn impl_def_datum( | |||
549 | let generic_params = generics(db.upcast(), impl_id.into()); | 549 | let generic_params = generics(db.upcast(), impl_id.into()); |
550 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 550 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
551 | let trait_ = trait_ref.trait_; | 551 | let trait_ = trait_ref.trait_; |
552 | let impl_type = if impl_id.lookup(db.upcast()).container.module(db.upcast()).krate == krate { | 552 | let impl_type = if impl_id.lookup(db.upcast()).container.module(db.upcast()).krate() == krate { |
553 | rust_ir::ImplType::Local | 553 | rust_ir::ImplType::Local |
554 | } else { | 554 | } else { |
555 | rust_ir::ImplType::External | 555 | rust_ir::ImplType::External |