From 31d3a56b1865c33ef54e5d76e606965c87676695 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 01:53:07 +0300 Subject: move adt to adt --- crates/ra_hir/src/adt.rs | 23 +++++++++++++++++++---- crates/ra_hir/src/lib.rs | 5 +++-- crates/ra_hir/src/ty.rs | 19 +------------------ 3 files changed, 23 insertions(+), 24 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index ad3f9c405..6b13b464d 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs @@ -3,17 +3,32 @@ use std::sync::Arc; -use ra_syntax::{ - ast::{self, NameOwner, StructFlavor} -}; +use ra_syntax::ast::{self, NameOwner, StructFlavor}; use crate::{ - Name, AsName, Struct, Enum, EnumVariant, + Name, AsName, Struct, Enum, EnumVariant, Crate, HirDatabase, type_ref::TypeRef, ids::LocationCtx, }; +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum AdtDef { + Struct(Struct), + Enum(Enum), +} +impl_froms!(AdtDef: Struct, Enum); + +impl AdtDef { + pub(crate) fn krate(self, db: &impl HirDatabase) -> Option { + match self { + AdtDef::Struct(s) => s.module(db), + AdtDef::Enum(e) => e.module(db), + } + .krate(db) + } +} + impl Struct { pub(crate) fn variant_data(&self, db: &impl HirDatabase) -> Arc { db.struct_data((*self).into()).variant_data.clone() diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 644affd44..596f9c38c 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -55,10 +55,11 @@ pub use self::{ ids::{HirFileId, MacroCallId, MacroCallLoc, HirInterner}, macros::{MacroDef, MacroInput, MacroExpansion}, nameres::{ItemMap, PerNs, Namespace, Resolution}, - ty::{Ty, AdtDef}, + ty::Ty, impl_block::{ImplBlock, ImplItem}, code_model_impl::function::{FnScopes, ScopesWithSyntaxMapping}, - docs::{Docs, Documentation} + docs::{Docs, Documentation}, + adt::AdtDef, }; pub use self::code_model_api::{ diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 1d5624f8f..c7f77e7a3 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -31,7 +31,7 @@ use rustc_hash::FxHashMap; use crate::{ Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock, - FnSignature, FnScopes, ModuleDef, Crate, + FnSignature, FnScopes, ModuleDef, AdtDef, db::HirDatabase, type_ref::{TypeRef, Mutability}, name::KnownName, @@ -162,23 +162,6 @@ impl Substs { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub enum AdtDef { - Struct(Struct), - Enum(Enum), -} -impl_froms!(AdtDef: Struct, Enum); - -impl AdtDef { - fn krate(self, db: &impl HirDatabase) -> Option { - match self { - AdtDef::Struct(s) => s.module(db), - AdtDef::Enum(e) => e.module(db), - } - .krate(db) - } -} - /// A type. This is based on the `TyKind` enum in rustc (librustc/ty/sty.rs). /// /// This should be cheap to clone. -- cgit v1.2.3