Move hir_def::adt to hir_def::data::adt

This commit is contained in:
Lukas Wirth 2023-04-06 19:23:29 +02:00
parent 3dd17bcfc3
commit 8e7c104b3a
18 changed files with 33 additions and 26 deletions

View file

@ -26,10 +26,12 @@ use syntax::{
}; };
use crate::{ use crate::{
adt::StructKind, body::{
body::{Body, BodySourceMap, Expander, ExprPtr, LabelPtr, LabelSource, PatPtr}, Body, BodyDiagnostic, BodySourceMap, Expander, ExprPtr, ExprSource, LabelPtr, LabelSource,
body::{BodyDiagnostic, ExprSource, PatSource}, PatPtr, PatSource,
},
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}, builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
data::adt::StructKind,
db::DefDatabase, db::DefDatabase,
expr::{ expr::{
dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId, dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId,

View file

@ -1,5 +1,7 @@
//! Contains basic data about various HIR declarations. //! Contains basic data about various HIR declarations.
pub mod adt;
use std::sync::Arc; use std::sync::Arc;
use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroDefKind}; use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroDefKind};

View file

@ -9,10 +9,10 @@ use la_arena::ArenaMap;
use syntax::{ast, AstPtr}; use syntax::{ast, AstPtr};
use crate::{ use crate::{
adt::{EnumData, StructData},
attr::{Attrs, AttrsWithOwner}, attr::{Attrs, AttrsWithOwner},
body::{scope::ExprScopes, Body, BodySourceMap}, body::{scope::ExprScopes, Body, BodySourceMap},
data::{ data::{
adt::{EnumData, StructData},
ConstData, FunctionData, ImplData, Macro2Data, MacroRulesData, ProcMacroData, StaticData, ConstData, FunctionData, ImplData, Macro2Data, MacroRulesData, ProcMacroData, StaticData,
TraitAliasData, TraitData, TypeAliasData, TraitAliasData, TraitData, TypeAliasData,
}, },

View file

@ -29,7 +29,6 @@ pub mod keys;
pub mod item_tree; pub mod item_tree;
pub mod adt;
pub mod data; pub mod data;
pub mod generics; pub mod generics;
pub mod lang_item; pub mod lang_item;
@ -82,8 +81,8 @@ use syntax::ast;
use ::tt::token_id as tt; use ::tt::token_id as tt;
use crate::{ use crate::{
adt::VariantData,
builtin_type::BuiltinType, builtin_type::BuiltinType,
data::adt::VariantData,
item_tree::{ item_tree::{
Const, Enum, Function, Impl, ItemTreeId, ItemTreeNode, MacroDef, MacroRules, ModItem, Const, Enum, Function, Impl, ItemTreeId, ItemTreeNode, MacroDef, MacroRules, ModItem,
Static, Struct, Trait, TraitAlias, TypeAlias, Union, Static, Struct, Trait, TraitAlias, TypeAlias, Union,
@ -236,7 +235,7 @@ pub struct EnumVariantId {
pub local_id: LocalEnumVariantId, pub local_id: LocalEnumVariantId,
} }
pub type LocalEnumVariantId = Idx<adt::EnumVariantData>; pub type LocalEnumVariantId = Idx<data::adt::EnumVariantData>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FieldId { pub struct FieldId {
@ -244,7 +243,7 @@ pub struct FieldId {
pub local_id: LocalFieldId, pub local_id: LocalFieldId,
} }
pub type LocalFieldId = Idx<adt::FieldData>; pub type LocalFieldId = Idx<data::adt::FieldData>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ConstId(salsa::InternId); pub struct ConstId(salsa::InternId);

View file

@ -331,11 +331,11 @@ impl DefMap {
Some(local_id) => { Some(local_id) => {
let variant = EnumVariantId { parent: e, local_id }; let variant = EnumVariantId { parent: e, local_id };
match &*enum_data.variants[local_id].variant_data { match &*enum_data.variants[local_id].variant_data {
crate::adt::VariantData::Record(_) => { crate::data::adt::VariantData::Record(_) => {
PerNs::types(variant.into(), Visibility::Public) PerNs::types(variant.into(), Visibility::Public)
} }
crate::adt::VariantData::Tuple(_) crate::data::adt::VariantData::Tuple(_)
| crate::adt::VariantData::Unit => { | crate::data::adt::VariantData::Unit => {
PerNs::both(variant.into(), variant.into(), Visibility::Public) PerNs::both(variant.into(), variant.into(), Visibility::Public)
} }
} }

View file

@ -16,7 +16,7 @@ use std::fmt;
use base_db::CrateId; use base_db::CrateId;
use hir_def::{ use hir_def::{
adt::VariantData, data::adt::VariantData,
expr::{Pat, PatId}, expr::{Pat, PatId},
src::HasSource, src::HasSource,
AdtId, AttrDefId, ConstId, EnumId, FunctionId, ItemContainerId, Lookup, ModuleDefId, StaticId, AdtId, AttrDefId, ConstId, EnumId, FunctionId, ItemContainerId, Lookup, ModuleDefId, StaticId,

View file

@ -12,7 +12,7 @@ pub(crate) mod usefulness;
use chalk_ir::Mutability; use chalk_ir::Mutability;
use hir_def::{ use hir_def::{
adt::VariantData, body::Body, expr::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId, body::Body, data::adt::VariantData, expr::PatId, AdtId, EnumVariantId, LocalFieldId, VariantId,
}; };
use hir_expand::name::Name; use hir_expand::name::Name;
use stdx::{always, never}; use stdx::{always, never};

View file

@ -7,8 +7,8 @@ use std::fmt::{self, Debug};
use base_db::CrateId; use base_db::CrateId;
use chalk_ir::{BoundVar, TyKind}; use chalk_ir::{BoundVar, TyKind};
use hir_def::{ use hir_def::{
adt::VariantData,
body, body,
data::adt::VariantData,
db::DefDatabase, db::DefDatabase,
find_path, find_path,
generics::{TypeOrConstParamData, TypeParamProvenance}, generics::{TypeOrConstParamData, TypeParamProvenance},

View file

@ -6,8 +6,8 @@ use chalk_ir::{
DebruijnIndex, DebruijnIndex,
}; };
use hir_def::{ use hir_def::{
adt::VariantData, attr::Attrs, visibility::Visibility, AdtId, EnumVariantId, HasModule, Lookup, attr::Attrs, data::adt::VariantData, visibility::Visibility, AdtId, EnumVariantId, HasModule,
ModuleId, VariantId, Lookup, ModuleId, VariantId,
}; };
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;

View file

@ -1,6 +1,6 @@
//! Functions to detect special lang items //! Functions to detect special lang items
use hir_def::{adt::StructFlags, lang_item::LangItem, AdtId}; use hir_def::{data::adt::StructFlags, lang_item::LangItem, AdtId};
use hir_expand::name::Name; use hir_expand::name::Name;
use crate::db::HirDatabase; use crate::db::HirDatabase;

View file

@ -3,7 +3,7 @@
use std::ops::Bound; use std::ops::Bound;
use hir_def::{ use hir_def::{
adt::VariantData, data::adt::VariantData,
layout::{Integer, IntegerExt, Layout, LayoutCalculator, LayoutError, RustcEnumVariantIdx}, layout::{Integer, IntegerExt, Layout, LayoutCalculator, LayoutError, RustcEnumVariantIdx},
AdtId, EnumVariantId, HasModule, LocalEnumVariantId, VariantId, AdtId, EnumVariantId, HasModule, LocalEnumVariantId, VariantId,
}; };

View file

@ -18,9 +18,9 @@ use chalk_ir::{
use either::Either; use either::Either;
use hir_def::{ use hir_def::{
adt::StructKind,
body::{Expander, LowerCtx}, body::{Expander, LowerCtx},
builtin_type::BuiltinType, builtin_type::BuiltinType,
data::adt::StructKind,
generics::{ generics::{
TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget, TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget,
}, },

View file

@ -7,9 +7,11 @@ use std::{ops::ControlFlow, sync::Arc};
use base_db::{CrateId, Edition}; use base_db::{CrateId, Edition};
use chalk_ir::{cast::Cast, Mutability, TyKind, UniverseIndex, WhereClause}; use chalk_ir::{cast::Cast, Mutability, TyKind, UniverseIndex, WhereClause};
use hir_def::{ use hir_def::{
adt::StructFlags, data::ImplData, item_scope::ItemScope, nameres::DefMap, AssocItemId, BlockId, data::{adt::StructFlags, ImplData},
ConstId, FunctionId, HasModule, ImplId, ItemContainerId, Lookup, ModuleDefId, ModuleId, item_scope::ItemScope,
TraitId, nameres::DefMap,
AssocItemId, BlockId, ConstId, FunctionId, HasModule, ImplId, ItemContainerId, Lookup,
ModuleDefId, ModuleId, TraitId,
}; };
use hir_expand::name::Name; use hir_expand::name::Name;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};

View file

@ -4,8 +4,8 @@ use std::{iter, mem, sync::Arc};
use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind}; use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind};
use hir_def::{ use hir_def::{
adt::{StructKind, VariantData},
body::Body, body::Body,
data::adt::{StructKind, VariantData},
expr::{ expr::{
Array, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm, Pat, PatId, Array, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm, Pat, PatId,
RecordFieldPat, RecordLitField, RecordFieldPat, RecordLitField,

View file

@ -1,6 +1,6 @@
//! HirDisplay implementations for various hir types. //! HirDisplay implementations for various hir types.
use hir_def::{ use hir_def::{
adt::VariantData, data::adt::VariantData,
generics::{ generics::{
TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget, TypeOrConstParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget,
}, },

View file

@ -39,8 +39,8 @@ use arrayvec::ArrayVec;
use base_db::{CrateDisplayName, CrateId, CrateOrigin, Edition, FileId, ProcMacroKind}; use base_db::{CrateDisplayName, CrateId, CrateOrigin, Edition, FileId, ProcMacroKind};
use either::Either; use either::Either;
use hir_def::{ use hir_def::{
adt::VariantData,
body::{BodyDiagnostic, SyntheticSyntax}, body::{BodyDiagnostic, SyntheticSyntax},
data::adt::VariantData,
expr::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat}, expr::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat},
generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance}, generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance},
item_tree::ItemTreeNode, item_tree::ItemTreeNode,
@ -109,9 +109,9 @@ pub use crate::{
pub use { pub use {
cfg::{CfgAtom, CfgExpr, CfgOptions}, cfg::{CfgAtom, CfgExpr, CfgOptions},
hir_def::{ hir_def::{
adt::StructKind,
attr::{Attrs, AttrsWithOwner, Documentation}, attr::{Attrs, AttrsWithOwner, Documentation},
builtin_attr::AttributeTemplate, builtin_attr::AttributeTemplate,
data::adt::StructKind,
find_path::PrefixKind, find_path::PrefixKind,
import_map, import_map,
nameres::ModuleSource, nameres::ModuleSource,

View file

@ -116,9 +116,11 @@ trait AddRewrite {
new: Vec<T>, new: Vec<T>,
target: TextRange, target: TextRange,
) -> Option<()>; ) -> Option<()>;
fn yeet() {}
} }
impl AddRewrite for Assists { impl AddRewrite for Assists {
fn yeet() {}
fn add_rewrite<T: AstNode>( fn add_rewrite<T: AstNode>(
&mut self, &mut self,
label: &str, label: &str,