impl Trait {
pub fn module(self, db: &impl DefDatabase) -> Module {
- Module { id: self.id.lookup(db).container }
+ Module { id: self.id.lookup(db).container.module(db) }
}
pub fn name(self, db: &impl DefDatabase) -> Name {
path::Path,
type_ref::{Mutability, TypeRef},
ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc,
- StructLoc, TypeAliasLoc, UnionLoc,
+ StructLoc, TraitLoc, TypeAliasLoc, UnionLoc,
};
pub(super) fn lower(
let ast_id = self.expander.ast_id(&def);
UnionLoc { container, ast_id }.intern(self.db).into()
}
- _ => continue,
+ ast::ModuleItem::TraitDef(def) => {
+ let ast_id = self.expander.ast_id(&def);
+ TraitLoc { container, ast_id }.intern(self.db).into()
+ }
+ ast::ModuleItem::ImplBlock(_)
+ | ast::ModuleItem::UseItem(_)
+ | ast::ModuleItem::ExternCrateItem(_)
+ | ast::ModuleItem::Module(_) => continue,
};
self.body.defs.push(def)
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TraitLoc {
- pub container: ModuleId,
+ pub container: ContainerId,
pub ast_id: AstId<ast::TraitDef>,
}
match *self {
AssocContainerId::ContainerId(it) => it.module(db),
AssocContainerId::ImplId(it) => it.lookup(db).container,
- AssocContainerId::TraitId(it) => it.lookup(db).container,
+ AssocContainerId::TraitId(it) => it.lookup(db).container.module(db),
}
}
}
match self {
GenericDefId::FunctionId(it) => it.lookup(db).module(db),
GenericDefId::AdtId(it) => it.module(db),
- GenericDefId::TraitId(it) => it.lookup(db).container,
+ GenericDefId::TraitId(it) => it.lookup(db).container.module(db),
GenericDefId::TypeAliasId(it) => it.lookup(db).module(db),
GenericDefId::ImplId(it) => it.lookup(db).container,
GenericDefId::EnumVariantId(it) => it.parent.lookup(db).container.module(db),
PerNs::values(def.into())
}
raw::DefKind::Trait(ast_id) => {
- let def = TraitLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) }
+ let def = TraitLoc { container, ast_id: AstId::new(self.file_id, ast_id) }
.intern(self.def_collector.db);
PerNs::types(def.into())
};
use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum};
-use hir_def::{AssocContainerId, AssocItemId, GenericDefId, ImplId, Lookup, TraitId, TypeAliasId};
+use hir_def::{
+ AssocContainerId, AssocItemId, GenericDefId, HasModule, ImplId, Lookup, TraitId, TypeAliasId,
+};
use ra_db::{
salsa::{InternId, InternKey},
CrateId,
let bound_vars = Substs::bound_vars(&generic_params);
let flags = chalk_rust_ir::TraitFlags {
auto: trait_data.auto,
- upstream: trait_.lookup(db).container.krate != krate,
+ upstream: trait_.lookup(db).container.module(db).krate != krate,
non_enumerable: true,
coinductive: false, // only relevant for Chalk testing
// FIXME set these flags correctly