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::{
adt::StructKind,
body::{Body, BodySourceMap, Expander, ExprPtr, LabelPtr, LabelSource, PatPtr},
body::{BodyDiagnostic, ExprSource, PatSource},
body::{
Body, BodyDiagnostic, BodySourceMap, Expander, ExprPtr, ExprSource, LabelPtr, LabelSource,
PatPtr, PatSource,
},
builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
data::adt::StructKind,
db::DefDatabase,
expr::{
dummy_expr_id, Array, Binding, BindingAnnotation, BindingId, ClosureKind, Expr, ExprId,

View file

@ -1,5 +1,7 @@
//! Contains basic data about various HIR declarations.
pub mod adt;
use std::sync::Arc;
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 crate::{
adt::{EnumData, StructData},
attr::{Attrs, AttrsWithOwner},
body::{scope::ExprScopes, Body, BodySourceMap},
data::{
adt::{EnumData, StructData},
ConstData, FunctionData, ImplData, Macro2Data, MacroRulesData, ProcMacroData, StaticData,
TraitAliasData, TraitData, TypeAliasData,
},

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@ pub(crate) mod usefulness;
use chalk_ir::Mutability;
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 stdx::{always, never};

View file

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

View file

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

View file

@ -1,6 +1,6 @@
//! 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 crate::db::HirDatabase;

View file

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

View file

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

View file

@ -7,9 +7,11 @@ use std::{ops::ControlFlow, sync::Arc};
use base_db::{CrateId, Edition};
use chalk_ir::{cast::Cast, Mutability, TyKind, UniverseIndex, WhereClause};
use hir_def::{
adt::StructFlags, data::ImplData, item_scope::ItemScope, nameres::DefMap, AssocItemId, BlockId,
ConstId, FunctionId, HasModule, ImplId, ItemContainerId, Lookup, ModuleDefId, ModuleId,
TraitId,
data::{adt::StructFlags, ImplData},
item_scope::ItemScope,
nameres::DefMap,
AssocItemId, BlockId, ConstId, FunctionId, HasModule, ImplId, ItemContainerId, Lookup,
ModuleDefId, ModuleId, TraitId,
};
use hir_expand::name::Name;
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 hir_def::{
adt::{StructKind, VariantData},
body::Body,
data::adt::{StructKind, VariantData},
expr::{
Array, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm, Pat, PatId,
RecordFieldPat, RecordLitField,

View file

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

View file

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

View file

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