diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index f765490b011..989818c0e98 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -60,6 +60,13 @@ use crate::{ids::MacroFileKind, resolve::Resolver}; pub use crate::{ adt::VariantDef, + code_model::{ + docs::{DocDef, Docs, Documentation}, + src::{HasBodySource, HasSource, Source}, + Adt, AssocItem, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, + DefWithBody, Enum, EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module, + ModuleDef, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, + }, expr::ExprScopes, from_source::FromSource, generics::{GenericDef, GenericParam, GenericParams, HasGenericParams}, @@ -73,17 +80,9 @@ pub use crate::{ }, }; -pub use self::code_model::{ - docs::{DocDef, Docs, Documentation}, - src::{HasBodySource, HasSource, Source}, - Adt, AssocItem, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, - Enum, EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module, ModuleDef, - ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, -}; - pub use hir_def::{ - either::Either, name::Name, path::{Path, PathKind}, type_ref::Mutability, }; +pub use hir_expand::either::Either; diff --git a/crates/ra_hir_def/src/hygiene.rs b/crates/ra_hir_def/src/hygiene.rs index e1ae58a3bc9..f51c46fcb86 100644 --- a/crates/ra_hir_def/src/hygiene.rs +++ b/crates/ra_hir_def/src/hygiene.rs @@ -4,14 +4,12 @@ //! this moment, this is horribly incomplete and handles only `$crate`. // Should this be moved to `hir_expand`? Seems like it. +use hir_expand::either::Either; use hir_expand::{db::AstDatabase, HirFileId}; use ra_db::CrateId; use ra_syntax::ast; -use crate::{ - either::Either, - name::{AsName, Name}, -}; +use crate::name::{AsName, Name}; #[derive(Debug)] pub struct Hygiene { diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 61ccdb30d2c..0de728dc1a1 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -8,7 +8,6 @@ //! actually true. pub mod db; -pub mod either; pub mod attr; pub mod name; pub mod path; diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 636364628b2..f1896c0cc08 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -2,7 +2,7 @@ use std::{ops::Index, sync::Arc}; -use hir_expand::{ast_id_map::AstIdMap, db::AstDatabase}; +use hir_expand::{ast_id_map::AstIdMap, db::AstDatabase, either::Either}; use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; use ra_syntax::{ ast::{self, AttrsOwner, NameOwner}, @@ -12,7 +12,6 @@ use ra_syntax::{ use crate::{ attr::Attr, db::DefDatabase2, - either::Either, hygiene::Hygiene, name::{AsName, Name}, path::Path, @@ -41,10 +40,8 @@ pub struct ImportSourceMap { type ImportSourcePtr = Either, AstPtr>; type ImportSource = Either; -impl ImportSourcePtr { - fn to_node(self, file: &SourceFile) -> ImportSource { - self.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax())) - } +fn to_node(ptr: ImportSourcePtr, file: &SourceFile) -> ImportSource { + ptr.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax())) } impl ImportSourceMap { @@ -58,7 +55,7 @@ impl ImportSourceMap { ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), }; - self.map[import].to_node(&file) + to_node(self.map[import], &file) } } diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 39f394c3f75..8d57e776162 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -2,6 +2,7 @@ use std::{iter, sync::Arc}; +use hir_expand::either::Either; use ra_db::CrateId; use ra_syntax::{ ast::{self, NameOwner, TypeAscriptionOwner}, @@ -9,7 +10,6 @@ use ra_syntax::{ }; use crate::{ - either::Either, hygiene::Hygiene, name::{self, AsName, Name}, type_ref::TypeRef, diff --git a/crates/ra_hir_def/src/either.rs b/crates/ra_hir_expand/src/either.rs similarity index 100% rename from crates/ra_hir_def/src/either.rs rename to crates/ra_hir_expand/src/either.rs diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 3c0ef8f1c05..6359b2b4d93 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -6,6 +6,7 @@ pub mod db; pub mod ast_id_map; +pub mod either; use std::hash::{Hash, Hasher};