cleanup hir db imports

This commit is contained in:
Aleksey Kladov 2019-09-08 09:53:49 +03:00
parent 787f1206a9
commit 6021a2a83a
24 changed files with 65 additions and 43 deletions

View file

@ -7,8 +7,10 @@ use ra_arena::{impl_arena_id, Arena, RawId};
use ra_syntax::ast::{self, NameOwner, StructKind, TypeAscriptionOwner}; use ra_syntax::ast::{self, NameOwner, StructKind, TypeAscriptionOwner};
use crate::{ use crate::{
type_ref::TypeRef, AsName, AstDatabase, Crate, DefDatabase, Enum, EnumVariant, FieldSource, db::{AstDatabase, DefDatabase, HirDatabase},
HasSource, HirDatabase, Name, Source, Struct, StructField, Union, type_ref::TypeRef,
AsName, Crate, Enum, EnumVariant, FieldSource, HasSource, Name, Source, Struct, StructField,
Union,
}; };
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View file

@ -8,6 +8,7 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
use crate::{ use crate::{
adt::{EnumVariantId, StructFieldId, VariantDef}, adt::{EnumVariantId, StructFieldId, VariantDef},
db::{AstDatabase, DefDatabase, HirDatabase},
diagnostics::DiagnosticSink, diagnostics::DiagnosticSink,
expr::{validation::ExprValidator, Body, BodySourceMap}, expr::{validation::ExprValidator, Body, BodySourceMap},
generics::HasGenericParams, generics::HasGenericParams,
@ -29,7 +30,7 @@ use crate::{
}, },
type_ref::Mutability, type_ref::Mutability,
type_ref::TypeRef, type_ref::TypeRef,
AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, Name, Ty, AsName, AstId, Either, HasSource, Name, Ty,
}; };
/// hir::Crate describes a single crate. It's the main interface with which /// hir::Crate describes a single crate. It's the main interface with which

View file

@ -3,8 +3,9 @@ use std::sync::Arc;
use ra_syntax::ast; use ra_syntax::ast;
use crate::{ use crate::{
AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource, db::{AstDatabase, DefDatabase, HirDatabase},
HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union, Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static, Struct,
StructField, Trait, TypeAlias, Union,
}; };
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View file

@ -4,9 +4,10 @@ use ra_syntax::{
}; };
use crate::{ use crate::{
ids::AstItemDef, AstDatabase, Const, DefDatabase, Either, Enum, EnumVariant, FieldSource, db::{AstDatabase, DefDatabase, HirDatabase},
Function, HasBody, HirDatabase, HirFileId, MacroDef, Module, ModuleSource, Static, Struct, ids::AstItemDef,
StructField, Trait, TypeAlias, Union, Const, Either, Enum, EnumVariant, FieldSource, Function, HasBody, HirFileId, MacroDef, Module,
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
}; };
#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]

View file

@ -3,7 +3,7 @@ use std::{any::Any, fmt};
use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange};
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use crate::{HirDatabase, HirFileId, Name, Source}; use crate::{db::HirDatabase, HirFileId, Name, Source};
/// Diagnostic defines hir API for errors and warnings. /// Diagnostic defines hir API for errors and warnings.
/// ///

View file

@ -9,10 +9,11 @@ use ra_syntax::{ast, AstPtr};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use crate::{ use crate::{
db::HirDatabase,
path::GenericArgs, path::GenericArgs,
ty::primitive::{UncertainFloatTy, UncertainIntTy}, ty::primitive::{UncertainFloatTy, UncertainIntTy},
type_ref::{Mutability, TypeRef}, type_ref::{Mutability, TypeRef},
DefWithBody, Either, HasSource, HirDatabase, Name, Path, Resolver, Source, DefWithBody, Either, HasSource, Name, Path, Resolver, Source,
}; };
pub use self::scope::ExprScopes; pub use self::scope::ExprScopes;

View file

@ -9,12 +9,13 @@ use ra_syntax::{
use test_utils::tested_by; use test_utils::tested_by;
use crate::{ use crate::{
db::HirDatabase,
name::{AsName, Name, SELF_PARAM}, name::{AsName, Name, SELF_PARAM},
path::GenericArgs, path::GenericArgs,
ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
type_ref::TypeRef, type_ref::TypeRef,
DefWithBody, Either, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver,
Resolver, Source, Source,
}; };
use super::{ use super::{

View file

@ -4,8 +4,9 @@ use ra_arena::{impl_arena_id, Arena, RawId};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use crate::{ use crate::{
db::HirDatabase,
expr::{Body, Expr, ExprId, Pat, PatId, Statement}, expr::{Body, Expr, ExprId, Pat, PatId, Statement},
DefWithBody, HirDatabase, Name, DefWithBody, Name,
}; };
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]

View file

@ -5,12 +5,13 @@ use rustc_hash::FxHashSet;
use crate::{ use crate::{
adt::AdtDef, adt::AdtDef,
db::HirDatabase,
diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr}, diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr},
expr::AstPtr, expr::AstPtr,
name, name,
path::{PathKind, PathSegment}, path::{PathKind, PathSegment},
ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
Function, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution, Function, ModuleDef, Name, Path, PerNs, Resolution,
}; };
use super::{Expr, ExprId, RecordLitField}; use super::{Expr, ExprId, RecordLitField};

View file

@ -8,7 +8,10 @@ use ra_db::{salsa, FileId};
use ra_prof::profile; use ra_prof::profile;
use ra_syntax::{ast, AstNode, Parse, SyntaxNode}; use ra_syntax::{ast, AstNode, Parse, SyntaxNode};
use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source}; use crate::{
db::{AstDatabase, DefDatabase, InternDatabase},
AstId, FileAstId, Module, Source,
};
/// hir makes heavy use of ids: integer (u32) handlers to various things. You /// hir makes heavy use of ids: integer (u32) handlers to various things. You
/// can think of id as a pointer (but without a lifetime) or a file descriptor /// can think of id as a pointer (but without a lifetime) or a file descriptor

View file

@ -9,13 +9,13 @@ use ra_syntax::{
use crate::{ use crate::{
code_model::{Module, ModuleSource}, code_model::{Module, ModuleSource},
db::{AstDatabase, DefDatabase, HirDatabase},
generics::HasGenericParams, generics::HasGenericParams,
ids::LocationCtx, ids::LocationCtx,
resolve::Resolver, resolve::Resolver,
ty::Ty, ty::Ty,
type_ref::TypeRef, type_ref::TypeRef,
AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef, Const, Function, HasSource, HirFileId, Source, TraitRef, TypeAlias,
TypeAlias,
}; };
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, Default, PartialEq, Eq)]

View file

@ -4,8 +4,8 @@ use std::sync::Arc;
use ra_syntax::{ast::AttrsOwner, SmolStr}; use ra_syntax::{ast::AttrsOwner, SmolStr};
use crate::{ use crate::{
AstDatabase, Crate, DefDatabase, Enum, Function, HasSource, HirDatabase, ImplBlock, Module, db::{AstDatabase, DefDatabase, HirDatabase},
ModuleDef, Static, Struct, Trait, Crate, Enum, Function, HasSource, ImplBlock, Module, ModuleDef, Static, Struct, Trait,
}; };
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

View file

@ -49,7 +49,6 @@ mod code_model;
mod marks; mod marks;
use crate::{ use crate::{
db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase},
ids::MacroFileKind, ids::MacroFileKind,
name::AsName, name::AsName,
resolve::Resolver, resolve::Resolver,

View file

@ -65,9 +65,12 @@ use rustc_hash::{FxHashMap, FxHashSet};
use test_utils::tested_by; use test_utils::tested_by;
use crate::{ use crate::{
diagnostics::DiagnosticSink, either::Either, ids::MacroDefId, db::{AstDatabase, DefDatabase},
nameres::diagnostics::DefDiagnostic, AstDatabase, AstId, BuiltinType, Crate, DefDatabase, diagnostics::DiagnosticSink,
HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait, either::Either,
ids::MacroDefId,
nameres::diagnostics::DefDiagnostic,
AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
}; };
pub(crate) use self::raw::{ImportSourceMap, RawItems}; pub(crate) use self::raw::{ImportSourceMap, RawItems};
@ -516,9 +519,10 @@ mod diagnostics {
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use crate::{ use crate::{
db::{AstDatabase, DefDatabase},
diagnostics::{DiagnosticSink, UnresolvedModule}, diagnostics::{DiagnosticSink, UnresolvedModule},
nameres::CrateModuleId, nameres::CrateModuleId,
AstDatabase, AstId, DefDatabase, AstId,
}; };
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]

View file

@ -4,6 +4,7 @@ use rustc_hash::FxHashMap;
use test_utils::tested_by; use test_utils::tested_by;
use crate::{ use crate::{
db::DefDatabase,
either::Either, either::Either,
ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind},
name::MACRO_RULES, name::MACRO_RULES,
@ -13,8 +14,8 @@ use crate::{
raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData, ModuleDef, PerNs, raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData, ModuleDef, PerNs,
ReachedFixedPoint, Resolution, ResolveMode, ReachedFixedPoint, Resolution, ResolveMode,
}, },
AstId, Const, DefDatabase, Enum, Function, HirFileId, MacroDef, Module, Name, Path, Static, AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, Static, Struct, Trait,
Struct, Trait, TypeAlias, Union, TypeAlias, Union,
}; };
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
@ -699,7 +700,7 @@ mod tests {
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use super::*; use super::*;
use crate::{mock::MockDatabase, Crate, DefDatabase}; use crate::{db::DefDatabase, mock::MockDatabase, Crate};
use ra_arena::Arena; use ra_arena::Arena;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;

View file

@ -6,7 +6,7 @@ use ra_db::{FileId, SourceRoot};
use ra_syntax::SmolStr; use ra_syntax::SmolStr;
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use crate::{DefDatabase, HirFileId, Name}; use crate::{db::DefDatabase, HirFileId, Name};
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub(super) struct ParentModule<'a> { pub(super) struct ParentModule<'a> {

View file

@ -8,8 +8,8 @@ use ra_syntax::{
use test_utils::tested_by; use test_utils::tested_by;
use crate::{ use crate::{
AsName, AstDatabase, AstIdMap, DefDatabase, Either, FileAstId, HirFileId, ModuleSource, Name, db::{AstDatabase, DefDatabase},
Path, AsName, AstIdMap, Either, FileAstId, HirFileId, ModuleSource, Name, Path,
}; };
/// `RawItems` is a set of top-level items in a file (except for impls). /// `RawItems` is a set of top-level items in a file (except for impls).

View file

@ -18,6 +18,7 @@ use ra_syntax::{
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use crate::{ use crate::{
db::HirDatabase,
expr::{ expr::{
self, self,
scope::{ExprScopes, ScopeId}, scope::{ExprScopes, ScopeId},
@ -27,9 +28,8 @@ use crate::{
name, name,
path::{PathKind, PathSegment}, path::{PathKind, PathSegment},
ty::method_resolution::implements_trait, ty::method_resolution::implements_trait,
AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirDatabase, AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirFileId, MacroDef,
HirFileId, MacroDef, Module, ModuleDef, Name, Path, PerNs, Resolution, Resolver, Static, Module, ModuleDef, Name, Path, PerNs, Resolution, Resolver, Static, Struct, Trait, Ty,
Struct, Trait, Ty,
}; };
/// Locates the module by `FileId`. Picks topmost module in the file. /// Locates the module by `FileId`. Picks topmost module in the file.

View file

@ -7,7 +7,7 @@ use std::{
use ra_arena::{impl_arena_id, Arena, RawId}; use ra_arena::{impl_arena_id, Arena, RawId};
use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr}; use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr};
use crate::{AstDatabase, HirFileId}; use crate::{db::AstDatabase, HirFileId};
/// `AstId` points to an AST node in any file. /// `AstId` points to an AST node in any file.
/// ///

View file

@ -6,8 +6,10 @@ use std::sync::Arc;
use ra_syntax::ast::{self, NameOwner}; use ra_syntax::ast::{self, NameOwner};
use crate::{ use crate::{
ids::LocationCtx, name::AsName, AstDatabase, Const, DefDatabase, Function, HasSource, Module, db::{AstDatabase, DefDatabase},
Name, Trait, TypeAlias, ids::LocationCtx,
name::AsName,
Const, Function, HasSource, Module, Name, Trait, TypeAlias,
}; };
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -8,7 +8,7 @@ use std::iter::successors;
use log::{info, warn}; use log::{info, warn};
use super::{traits::Solution, Canonical, Ty, TypeWalk}; use super::{traits::Solution, Canonical, Ty, TypeWalk};
use crate::{name, HasGenericParams, HirDatabase, Resolver}; use crate::{db::HirDatabase, name, HasGenericParams, Resolver};
const AUTODEREF_RECURSION_LIMIT: usize = 10; const AUTODEREF_RECURSION_LIMIT: usize = 10;

View file

@ -35,6 +35,7 @@ use super::{
use crate::{ use crate::{
adt::VariantDef, adt::VariantDef,
code_model::{ModuleDef::Trait, TypeAlias}, code_model::{ModuleDef::Trait, TypeAlias},
db::HirDatabase,
diagnostics::DiagnosticSink, diagnostics::DiagnosticSink,
expr::{ expr::{
self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, Literal, Pat, PatId, self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, Literal, Pat, PatId,
@ -50,8 +51,8 @@ use crate::{
}, },
ty::infer::diagnostics::InferenceDiagnostic, ty::infer::diagnostics::InferenceDiagnostic,
type_ref::{Mutability, TypeRef}, type_ref::{Mutability, TypeRef},
AdtDef, ConstData, DefWithBody, FnData, Function, HasBody, HirDatabase, ImplItem, ModuleDef, AdtDef, ConstData, DefWithBody, FnData, Function, HasBody, ImplItem, ModuleDef, Name, Path,
Name, Path, StructField, StructField,
}; };
mod unify; mod unify;
@ -1614,9 +1615,10 @@ impl Expectation {
mod diagnostics { mod diagnostics {
use crate::{ use crate::{
db::HirDatabase,
diagnostics::{DiagnosticSink, NoSuchField}, diagnostics::{DiagnosticSink, NoSuchField},
expr::ExprId, expr::ExprId,
Function, HasSource, HirDatabase, Function, HasSource,
}; };
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]

View file

@ -14,6 +14,7 @@ use super::{
}; };
use crate::{ use crate::{
adt::VariantDef, adt::VariantDef,
db::HirDatabase,
generics::HasGenericParams, generics::HasGenericParams,
generics::{GenericDef, WherePredicate}, generics::{GenericDef, WherePredicate},
nameres::Namespace, nameres::Namespace,
@ -21,8 +22,8 @@ use crate::{
resolve::{Resolution, Resolver}, resolve::{Resolution, Resolver},
ty::AdtDef, ty::AdtDef,
type_ref::{TypeBound, TypeRef}, type_ref::{TypeBound, TypeRef},
BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct, BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField,
StructField, Trait, TypeAlias, Union, Trait, TypeAlias, Union,
}; };
impl Ty { impl Ty {

View file

@ -9,6 +9,7 @@ use rustc_hash::FxHashMap;
use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef};
use crate::{ use crate::{
db::HirDatabase,
generics::HasGenericParams, generics::HasGenericParams,
impl_block::{ImplBlock, ImplId, ImplItem}, impl_block::{ImplBlock, ImplId, ImplItem},
nameres::CrateModuleId, nameres::CrateModuleId,
@ -16,7 +17,7 @@ use crate::{
traits::TraitItem, traits::TraitItem,
ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy},
ty::{Ty, TypeCtor}, ty::{Ty, TypeCtor},
Crate, Function, HirDatabase, Module, Name, Trait, Crate, Function, Module, Name, Trait,
}; };
/// This is used as a key for indexing impls. /// This is used as a key for indexing impls.