mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-27 14:24:08 +00:00
Rename ContainerId -> AssocContainerId
This commit is contained in:
parent
67c2aea182
commit
8fc20b6503
@ -25,7 +25,7 @@ use crate::{
|
||||
path::GenericArgs,
|
||||
path::Path,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
ContainerId, DefWithBodyId, FunctionLoc, Intern,
|
||||
AssocContainerId, DefWithBodyId, FunctionLoc, Intern,
|
||||
};
|
||||
|
||||
pub(super) fn lower(
|
||||
@ -490,7 +490,7 @@ where
|
||||
}
|
||||
|
||||
fn collect_block_items(&mut self, block: &ast::Block) {
|
||||
let container = ContainerId::DefWithBodyId(self.def);
|
||||
let container = AssocContainerId::DefWithBodyId(self.def);
|
||||
for item in block.items() {
|
||||
match item {
|
||||
ast::ModuleItem::FnDef(def) => {
|
||||
|
@ -12,8 +12,8 @@ use crate::{
|
||||
db::DefDatabase,
|
||||
src::HasSource,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
AssocItemId, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, ImplId, Intern, Lookup,
|
||||
StaticId, TraitId, TypeAliasId, TypeAliasLoc,
|
||||
AssocContainerId, AssocItemId, ConstId, ConstLoc, FunctionId, FunctionLoc, ImplId, Intern,
|
||||
Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@ -99,7 +99,7 @@ impl TraitData {
|
||||
let auto = src.value.is_auto();
|
||||
let ast_id_map = db.ast_id_map(src.file_id);
|
||||
|
||||
let container = ContainerId::TraitId(tr);
|
||||
let container = AssocContainerId::TraitId(tr);
|
||||
let items = if let Some(item_list) = src.value.item_list() {
|
||||
item_list
|
||||
.impl_items()
|
||||
@ -180,7 +180,7 @@ impl ImplData {
|
||||
.map(|item_node| match item_node {
|
||||
ast::ImplItem::FnDef(it) => {
|
||||
let def = FunctionLoc {
|
||||
container: ContainerId::ImplId(id),
|
||||
container: AssocContainerId::ImplId(id),
|
||||
ast_id: AstId::new(src.file_id, items.ast_id(&it)),
|
||||
}
|
||||
.intern(db);
|
||||
@ -188,7 +188,7 @@ impl ImplData {
|
||||
}
|
||||
ast::ImplItem::ConstDef(it) => {
|
||||
let def = ConstLoc {
|
||||
container: ContainerId::ImplId(id),
|
||||
container: AssocContainerId::ImplId(id),
|
||||
ast_id: AstId::new(src.file_id, items.ast_id(&it)),
|
||||
}
|
||||
.intern(db);
|
||||
@ -196,7 +196,7 @@ impl ImplData {
|
||||
}
|
||||
ast::ImplItem::TypeAliasDef(it) => {
|
||||
let def = TypeAliasLoc {
|
||||
container: ContainerId::ImplId(id),
|
||||
container: AssocContainerId::ImplId(id),
|
||||
ast_id: AstId::new(src.file_id, items.ast_id(&it)),
|
||||
}
|
||||
.intern(db);
|
||||
|
@ -71,7 +71,7 @@ impl_intern_key!(FunctionId);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FunctionLoc {
|
||||
pub container: ContainerId,
|
||||
pub container: AssocContainerId,
|
||||
pub ast_id: AstId<ast::FnDef>,
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ pub struct ConstId(salsa::InternId);
|
||||
impl_intern_key!(ConstId);
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ConstLoc {
|
||||
pub container: ContainerId,
|
||||
pub container: AssocContainerId,
|
||||
pub ast_id: AstId<ast::ConstDef>,
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ impl_intern_key!(TypeAliasId);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TypeAliasLoc {
|
||||
pub container: ContainerId,
|
||||
pub container: AssocContainerId,
|
||||
pub ast_id: AstId<ast::TypeAliasDef>,
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ pub struct LocalTypeParamId(RawId);
|
||||
impl_arena_id!(LocalTypeParamId);
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum ContainerId {
|
||||
pub enum AssocContainerId {
|
||||
ModuleId(ModuleId),
|
||||
ImplId(ImplId),
|
||||
TraitId(TraitId),
|
||||
@ -479,13 +479,13 @@ pub trait HasModule {
|
||||
fn module(&self, db: &impl db::DefDatabase) -> ModuleId;
|
||||
}
|
||||
|
||||
impl HasModule for ContainerId {
|
||||
impl HasModule for AssocContainerId {
|
||||
fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
|
||||
match *self {
|
||||
ContainerId::ModuleId(it) => it,
|
||||
ContainerId::ImplId(it) => it.lookup(db).container,
|
||||
ContainerId::TraitId(it) => it.lookup(db).container,
|
||||
ContainerId::DefWithBodyId(it) => it.module(db),
|
||||
AssocContainerId::ModuleId(it) => it,
|
||||
AssocContainerId::ImplId(it) => it.lookup(db).container,
|
||||
AssocContainerId::TraitId(it) => it.lookup(db).container,
|
||||
AssocContainerId::DefWithBodyId(it) => it.module(db),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use crate::{
|
||||
},
|
||||
path::{ModPath, PathKind},
|
||||
per_ns::PerNs,
|
||||
AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern,
|
||||
AdtId, AssocContainerId, AstId, ConstLoc, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern,
|
||||
LocalImportId, LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc,
|
||||
TypeAliasLoc, UnionLoc,
|
||||
};
|
||||
@ -763,7 +763,7 @@ where
|
||||
let def: PerNs = match def.kind {
|
||||
raw::DefKind::Function(ast_id) => {
|
||||
let def = FunctionLoc {
|
||||
container: ContainerId::ModuleId(module),
|
||||
container: AssocContainerId::ModuleId(module),
|
||||
ast_id: AstId::new(self.file_id, ast_id),
|
||||
}
|
||||
.intern(self.def_collector.db);
|
||||
@ -787,7 +787,7 @@ where
|
||||
}
|
||||
raw::DefKind::Const(ast_id) => {
|
||||
let def = ConstLoc {
|
||||
container: ContainerId::ModuleId(module),
|
||||
container: AssocContainerId::ModuleId(module),
|
||||
ast_id: AstId::new(self.file_id, ast_id),
|
||||
}
|
||||
.intern(self.def_collector.db);
|
||||
@ -808,7 +808,7 @@ where
|
||||
}
|
||||
raw::DefKind::TypeAlias(ast_id) => {
|
||||
let def = TypeAliasLoc {
|
||||
container: ContainerId::ModuleId(module),
|
||||
container: AssocContainerId::ModuleId(module),
|
||||
ast_id: AstId::new(self.file_id, ast_id),
|
||||
}
|
||||
.intern(self.def_collector.db);
|
||||
|
@ -17,9 +17,9 @@ use crate::{
|
||||
nameres::{BuiltinShadowMode, CrateDefMap},
|
||||
path::{ModPath, PathKind},
|
||||
per_ns::PerNs,
|
||||
AdtId, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GenericDefId,
|
||||
HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId,
|
||||
TypeAliasId, TypeParamId, VariantId,
|
||||
AdtId, AssocContainerId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
|
||||
GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId,
|
||||
StructId, TraitId, TypeAliasId, TypeParamId, VariantId,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@ -580,13 +580,13 @@ impl HasResolver for DefWithBodyId {
|
||||
}
|
||||
}
|
||||
|
||||
impl HasResolver for ContainerId {
|
||||
impl HasResolver for AssocContainerId {
|
||||
fn resolver(self, db: &impl DefDatabase) -> Resolver {
|
||||
match self {
|
||||
ContainerId::TraitId(it) => it.resolver(db),
|
||||
ContainerId::ImplId(it) => it.resolver(db),
|
||||
ContainerId::ModuleId(it) => it.resolver(db),
|
||||
ContainerId::DefWithBodyId(it) => it.resolver(db),
|
||||
AssocContainerId::TraitId(it) => it.resolver(db),
|
||||
AssocContainerId::ImplId(it) => it.resolver(db),
|
||||
AssocContainerId::ModuleId(it) => it.resolver(db),
|
||||
AssocContainerId::DefWithBodyId(it) => it.resolver(db),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use hir_def::{
|
||||
expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp},
|
||||
path::{GenericArg, GenericArgs},
|
||||
resolver::resolver_for_expr,
|
||||
AdtId, ContainerId, Lookup, StructFieldId,
|
||||
AdtId, AssocContainerId, Lookup, StructFieldId,
|
||||
};
|
||||
use hir_expand::name::{name, Name};
|
||||
use ra_syntax::ast::RangeOp;
|
||||
@ -672,7 +672,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||
// add obligation for trait implementation, if this is a trait method
|
||||
match def {
|
||||
CallableDef::FunctionId(f) => {
|
||||
if let ContainerId::TraitId(trait_) = f.lookup(self.db).container {
|
||||
if let AssocContainerId::TraitId(trait_) = f.lookup(self.db).container {
|
||||
// construct a TraitDef
|
||||
let substs =
|
||||
a_ty.parameters.prefix(generics(self.db, trait_.into()).len());
|
||||
|
@ -5,7 +5,7 @@ use std::iter;
|
||||
use hir_def::{
|
||||
path::{Path, PathSegment},
|
||||
resolver::{ResolveValueResult, Resolver, TypeNs, ValueNs},
|
||||
AssocItemId, ContainerId, Lookup,
|
||||
AssocContainerId, AssocItemId, Lookup,
|
||||
};
|
||||
use hir_expand::name::Name;
|
||||
|
||||
@ -209,7 +209,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||
AssocItemId::TypeAliasId(_) => unreachable!(),
|
||||
};
|
||||
let substs = match container {
|
||||
ContainerId::ImplId(impl_id) => {
|
||||
AssocContainerId::ImplId(impl_id) => {
|
||||
let impl_substs = Substs::build_for_def(self.db, impl_id)
|
||||
.fill(iter::repeat_with(|| self.table.new_type_var()))
|
||||
.build();
|
||||
@ -221,7 +221,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||
self.unify(&impl_self_ty, &ty);
|
||||
Some(substs)
|
||||
}
|
||||
ContainerId::TraitId(trait_) => {
|
||||
AssocContainerId::TraitId(trait_) => {
|
||||
// we're picking this method
|
||||
let trait_substs = Substs::build_for_def(self.db, trait_)
|
||||
.push(ty.clone())
|
||||
@ -237,7 +237,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||
}));
|
||||
Some(substs)
|
||||
}
|
||||
ContainerId::ModuleId(_) | ContainerId::DefWithBodyId(_) => None,
|
||||
AssocContainerId::ModuleId(_) | AssocContainerId::DefWithBodyId(_) => None,
|
||||
};
|
||||
|
||||
self.write_assoc_resolution(id, item.into());
|
||||
|
@ -44,8 +44,8 @@ use std::sync::Arc;
|
||||
use std::{fmt, iter, mem};
|
||||
|
||||
use hir_def::{
|
||||
expr::ExprId, type_ref::Mutability, AdtId, ContainerId, DefWithBodyId, GenericDefId, HasModule,
|
||||
Lookup, TraitId, TypeAliasId,
|
||||
expr::ExprId, type_ref::Mutability, AdtId, AssocContainerId, DefWithBodyId, GenericDefId,
|
||||
HasModule, Lookup, TraitId, TypeAliasId,
|
||||
};
|
||||
use hir_expand::name::Name;
|
||||
use ra_db::{impl_intern_key, salsa, CrateId};
|
||||
@ -251,7 +251,7 @@ impl ProjectionTy {
|
||||
|
||||
fn trait_(&self, db: &impl HirDatabase) -> TraitId {
|
||||
match self.associated_ty.lookup(db).container {
|
||||
ContainerId::TraitId(it) => it,
|
||||
AssocContainerId::TraitId(it) => it,
|
||||
_ => panic!("projection ty without parent trait"),
|
||||
}
|
||||
}
|
||||
@ -943,7 +943,7 @@ impl HirDisplay for ApplicationTy {
|
||||
}
|
||||
TypeCtor::AssociatedType(type_alias) => {
|
||||
let trait_ = match type_alias.lookup(f.db).container {
|
||||
ContainerId::TraitId(it) => it,
|
||||
AssocContainerId::TraitId(it) => it,
|
||||
_ => panic!("not an associated type"),
|
||||
};
|
||||
let trait_name = f.db.trait_data(trait_).name.clone();
|
||||
|
@ -6,8 +6,8 @@ use std::sync::Arc;
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use hir_def::{
|
||||
lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AssocItemId, ContainerId,
|
||||
FunctionId, HasModule, ImplId, Lookup, TraitId,
|
||||
lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AssocContainerId,
|
||||
AssocItemId, FunctionId, HasModule, ImplId, Lookup, TraitId,
|
||||
};
|
||||
use hir_expand::name::Name;
|
||||
use ra_db::CrateId;
|
||||
@ -451,12 +451,12 @@ fn transform_receiver_ty(
|
||||
self_ty: &Canonical<Ty>,
|
||||
) -> Option<Ty> {
|
||||
let substs = match function_id.lookup(db).container {
|
||||
ContainerId::TraitId(_) => Substs::build_for_def(db, function_id)
|
||||
AssocContainerId::TraitId(_) => Substs::build_for_def(db, function_id)
|
||||
.push(self_ty.value.clone())
|
||||
.fill_with_unknown()
|
||||
.build(),
|
||||
ContainerId::ImplId(impl_id) => inherent_impl_substs(db, impl_id, &self_ty)?,
|
||||
ContainerId::ModuleId(_) | ContainerId::DefWithBodyId(_) => unreachable!(),
|
||||
AssocContainerId::ImplId(impl_id) => inherent_impl_substs(db, impl_id, &self_ty)?,
|
||||
AssocContainerId::ModuleId(_) | AssocContainerId::DefWithBodyId(_) => unreachable!(),
|
||||
};
|
||||
let sig = db.callable_item_signature(function_id.into());
|
||||
Some(sig.params()[0].clone().subst(&substs))
|
||||
|
@ -9,7 +9,7 @@ use chalk_ir::{
|
||||
};
|
||||
use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum};
|
||||
|
||||
use hir_def::{AssocItemId, ContainerId, GenericDefId, ImplId, Lookup, TraitId, TypeAliasId};
|
||||
use hir_def::{AssocContainerId, AssocItemId, GenericDefId, ImplId, Lookup, TraitId, TypeAliasId};
|
||||
use ra_db::{
|
||||
salsa::{InternId, InternKey},
|
||||
CrateId,
|
||||
@ -542,7 +542,7 @@ pub(crate) fn associated_ty_data_query(
|
||||
debug!("associated_ty_data {:?}", id);
|
||||
let type_alias: TypeAliasId = from_chalk(db, id);
|
||||
let trait_ = match type_alias.lookup(db).container {
|
||||
ContainerId::TraitId(t) => t,
|
||||
AssocContainerId::TraitId(t) => t,
|
||||
_ => panic!("associated type not in trait"),
|
||||
};
|
||||
let generic_params = generics(db, type_alias.into());
|
||||
@ -755,7 +755,7 @@ fn type_alias_associated_ty_value(
|
||||
) -> Arc<AssociatedTyValue<ChalkIr>> {
|
||||
let type_alias_data = db.type_alias_data(type_alias);
|
||||
let impl_id = match type_alias.lookup(db).container {
|
||||
ContainerId::ImplId(it) => it,
|
||||
AssocContainerId::ImplId(it) => it,
|
||||
_ => panic!("assoc ty value should be in impl"),
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@ use hir_def::{
|
||||
path::Path,
|
||||
resolver::{HasResolver, TypeNs},
|
||||
type_ref::TypeRef,
|
||||
ContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId, VariantId,
|
||||
AssocContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId, VariantId,
|
||||
};
|
||||
use hir_expand::name::{name, Name};
|
||||
|
||||
@ -155,8 +155,8 @@ fn parent_generic_def(db: &impl DefDatabase, def: GenericDefId) -> Option<Generi
|
||||
};
|
||||
|
||||
match container {
|
||||
ContainerId::ImplId(it) => Some(it.into()),
|
||||
ContainerId::TraitId(it) => Some(it.into()),
|
||||
ContainerId::ModuleId(_) | ContainerId::DefWithBodyId(_) => None,
|
||||
AssocContainerId::ImplId(it) => Some(it.into()),
|
||||
AssocContainerId::TraitId(it) => Some(it.into()),
|
||||
AssocContainerId::ModuleId(_) | AssocContainerId::DefWithBodyId(_) => None,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user