diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 6 |
5 files changed, 18 insertions, 9 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index d20e9de63..35e1f752b 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -553,7 +553,7 @@ pub struct Trait { | |||
553 | 553 | ||
554 | impl Trait { | 554 | impl Trait { |
555 | pub fn module(self, db: &impl DefDatabase) -> Module { | 555 | pub fn module(self, db: &impl DefDatabase) -> Module { |
556 | Module { id: self.id.lookup(db).container } | 556 | Module { id: self.id.lookup(db).container.module(db) } |
557 | } | 557 | } |
558 | 558 | ||
559 | pub fn name(self, db: &impl DefDatabase) -> Name { | 559 | pub fn name(self, db: &impl DefDatabase) -> Name { |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index b61f924b7..853e17bae 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -26,7 +26,7 @@ use crate::{ | |||
26 | path::Path, | 26 | path::Path, |
27 | type_ref::{Mutability, TypeRef}, | 27 | type_ref::{Mutability, TypeRef}, |
28 | ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc, | 28 | ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc, |
29 | StructLoc, TypeAliasLoc, UnionLoc, | 29 | StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, |
30 | }; | 30 | }; |
31 | 31 | ||
32 | pub(super) fn lower( | 32 | pub(super) fn lower( |
@@ -522,7 +522,14 @@ where | |||
522 | let ast_id = self.expander.ast_id(&def); | 522 | let ast_id = self.expander.ast_id(&def); |
523 | UnionLoc { container, ast_id }.intern(self.db).into() | 523 | UnionLoc { container, ast_id }.intern(self.db).into() |
524 | } | 524 | } |
525 | _ => continue, | 525 | ast::ModuleItem::TraitDef(def) => { |
526 | let ast_id = self.expander.ast_id(&def); | ||
527 | TraitLoc { container, ast_id }.intern(self.db).into() | ||
528 | } | ||
529 | ast::ModuleItem::ImplBlock(_) | ||
530 | | ast::ModuleItem::UseItem(_) | ||
531 | | ast::ModuleItem::ExternCrateItem(_) | ||
532 | | ast::ModuleItem::Module(_) => continue, | ||
526 | }; | 533 | }; |
527 | self.body.defs.push(def) | 534 | self.body.defs.push(def) |
528 | } | 535 | } |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 9b192b597..140eccf26 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -235,7 +235,7 @@ impl_intern_key!(TraitId); | |||
235 | 235 | ||
236 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 236 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
237 | pub struct TraitLoc { | 237 | pub struct TraitLoc { |
238 | pub container: ModuleId, | 238 | pub container: ContainerId, |
239 | pub ast_id: AstId<ast::TraitDef>, | 239 | pub ast_id: AstId<ast::TraitDef>, |
240 | } | 240 | } |
241 | 241 | ||
@@ -499,7 +499,7 @@ impl HasModule for AssocContainerId { | |||
499 | match *self { | 499 | match *self { |
500 | AssocContainerId::ContainerId(it) => it.module(db), | 500 | AssocContainerId::ContainerId(it) => it.module(db), |
501 | AssocContainerId::ImplId(it) => it.lookup(db).container, | 501 | AssocContainerId::ImplId(it) => it.lookup(db).container, |
502 | AssocContainerId::TraitId(it) => it.lookup(db).container, | 502 | AssocContainerId::TraitId(it) => it.lookup(db).container.module(db), |
503 | } | 503 | } |
504 | } | 504 | } |
505 | } | 505 | } |
@@ -548,7 +548,7 @@ impl HasModule for GenericDefId { | |||
548 | match self { | 548 | match self { |
549 | GenericDefId::FunctionId(it) => it.lookup(db).module(db), | 549 | GenericDefId::FunctionId(it) => it.lookup(db).module(db), |
550 | GenericDefId::AdtId(it) => it.module(db), | 550 | GenericDefId::AdtId(it) => it.module(db), |
551 | GenericDefId::TraitId(it) => it.lookup(db).container, | 551 | GenericDefId::TraitId(it) => it.lookup(db).container.module(db), |
552 | GenericDefId::TypeAliasId(it) => it.lookup(db).module(db), | 552 | GenericDefId::TypeAliasId(it) => it.lookup(db).module(db), |
553 | GenericDefId::ImplId(it) => it.lookup(db).container, | 553 | GenericDefId::ImplId(it) => it.lookup(db).container, |
554 | GenericDefId::EnumVariantId(it) => it.parent.lookup(db).container.module(db), | 554 | GenericDefId::EnumVariantId(it) => it.parent.lookup(db).container.module(db), |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 74c3d4670..a1ea130e0 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -802,7 +802,7 @@ where | |||
802 | PerNs::values(def.into()) | 802 | PerNs::values(def.into()) |
803 | } | 803 | } |
804 | raw::DefKind::Trait(ast_id) => { | 804 | raw::DefKind::Trait(ast_id) => { |
805 | let def = TraitLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 805 | let def = TraitLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
806 | .intern(self.def_collector.db); | 806 | .intern(self.def_collector.db); |
807 | 807 | ||
808 | PerNs::types(def.into()) | 808 | PerNs::types(def.into()) |
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 6a31014d8..dd4fa9664 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -9,7 +9,9 @@ use chalk_ir::{ | |||
9 | }; | 9 | }; |
10 | use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; | 10 | use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; |
11 | 11 | ||
12 | use hir_def::{AssocContainerId, AssocItemId, GenericDefId, ImplId, Lookup, TraitId, TypeAliasId}; | 12 | use hir_def::{ |
13 | AssocContainerId, AssocItemId, GenericDefId, HasModule, ImplId, Lookup, TraitId, TypeAliasId, | ||
14 | }; | ||
13 | use ra_db::{ | 15 | use ra_db::{ |
14 | salsa::{InternId, InternKey}, | 16 | salsa::{InternId, InternKey}, |
15 | CrateId, | 17 | CrateId, |
@@ -591,7 +593,7 @@ pub(crate) fn trait_datum_query( | |||
591 | let bound_vars = Substs::bound_vars(&generic_params); | 593 | let bound_vars = Substs::bound_vars(&generic_params); |
592 | let flags = chalk_rust_ir::TraitFlags { | 594 | let flags = chalk_rust_ir::TraitFlags { |
593 | auto: trait_data.auto, | 595 | auto: trait_data.auto, |
594 | upstream: trait_.lookup(db).container.krate != krate, | 596 | upstream: trait_.lookup(db).container.module(db).krate != krate, |
595 | non_enumerable: true, | 597 | non_enumerable: true, |
596 | coinductive: false, // only relevant for Chalk testing | 598 | coinductive: false, // only relevant for Chalk testing |
597 | // FIXME set these flags correctly | 599 | // FIXME set these flags correctly |