Repository: rust-analyzer/rust-analyzer
Pull request #2372 (2019-11-23 11:46:43)

Note that debugging infra is broken


Patch:
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 496b4ee8a4..4b3ec5457d 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -1,7 +1,6 @@
 //! FIXME: write short doc here
 
 pub(crate) mod src;
-pub(crate) mod docs;
 
 use std::sync::Arc;
 
@@ -9,11 +8,12 @@ use hir_def::{
     adt::VariantData,
     body::scope::ExprScopes,
     builtin_type::BuiltinType,
+    docs::Documentation,
     nameres::per_ns::PerNs,
     resolver::{HasResolver, TypeNs},
     type_ref::TypeRef,
-    AdtId, ContainerId, CrateModuleId, EnumVariantId, HasModule, ImplId, LocalEnumVariantId,
-    LocalStructFieldId, Lookup, ModuleId, StructFieldId, UnionId,
+    ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup,
+    ModuleId, UnionId,
 };
 use hir_expand::{
     diagnostics::DiagnosticSink,
@@ -1024,18 +1024,17 @@ pub trait HasAttrs {
 
 impl<T: Into<AttrDef>> HasAttrs for T {
     fn attrs(self, db: &impl DefDatabase) -> Attrs {
-        let def = self.into();
-        match def {
-            AttrDef::Module(it) => db.attrs(it.id.into()),
-            AttrDef::StructField(it) => db.attrs(StructFieldId::from(it).into()),
-            AttrDef::Adt(it) => db.attrs(AdtId::from(it).into()),
-            AttrDef::Function(it) => db.attrs(it.id.into()),
-            AttrDef::EnumVariant(it) => db.attrs(EnumVariantId::from(it).into()),
-            AttrDef::Static(it) => db.attrs(it.id.into()),
-            AttrDef::Const(it) => db.attrs(it.id.into()),
-            AttrDef::Trait(it) => db.attrs(it.id.into()),
-            AttrDef::TypeAlias(it) => db.attrs(it.id.into()),
-            AttrDef::MacroDef(it) => db.attrs(it.id.into()),
-        }
+        let def: AttrDef = self.into();
+        db.attrs(def.into())
+    }
+}
+
+pub trait Docs {
+    fn docs(&self, db: &impl HirDatabase) -> Option<Documentation>;
+}
+impl<T: Into<AttrDef> + Copy> Docs for T {
+    fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> {
+        let def: AttrDef = (*self).into();
+        db.documentation(def.into())
     }
 }
diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs
deleted file mode 100644
index e40efef34a..0000000000
--- a/crates/ra_hir/src/code_model/docs.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-//! FIXME: write short doc here
-
-use std::sync::Arc;
-
-use ra_syntax::ast;
-
-use crate::{
-    db::{AstDatabase, DefDatabase, HirDatabase},
-    Adt, Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static,
-    Struct, StructField, Trait, TypeAlias, Union,
-};
-
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
-pub enum DocDef {
-    Module(Module),
-    StructField(StructField),
-    Adt(Adt),
-    EnumVariant(EnumVariant),
-    Static(Static),
-    Const(Const),
-    Function(Function),
-    Trait(Trait),
-    TypeAlias(TypeAlias),
-    MacroDef(MacroDef),
-}
-
-impl_froms!(
-    DocDef: Module,
-    StructField,
-    Adt(Struct, Enum, Union),
-    EnumVariant,
-    Static,
-    Const,
-    Function,
-    Trait,
-    TypeAlias,
-    MacroDef
-);
-
-/// Holds documentation
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct Documentation(Arc<str>);
-
-impl Documentation {
-    fn new(s: &str) -> Documentation {
-        Documentation(s.into())
-    }
-
-    pub fn as_str(&self) -> &str {
-        &*self.0
-    }
-}
-
-impl Into<String> for Documentation {
-    fn into(self) -> String {
-        self.as_str().to_owned()
-    }
-}
-
-pub trait Docs {
-    fn docs(&self, db: &impl HirDatabase) -> Option<Documentation>;
-}
-
-pub(crate) fn docs_from_ast(node: &impl ast::DocCommentsOwner) -> Option<Documentation> {
-    node.doc_comment_text().map(|it| Documentation::new(&it))
-}
-
-pub(crate) fn documentation_query(
-    db: &(impl DefDatabase + AstDatabase),
-    def: DocDef,
-) -> Option<Documentation> {
-    match def {
-        DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.value),
-        DocDef::StructField(it) => match it.source(db).value {
-            FieldSource::Named(named) => docs_from_ast(&named),
-            FieldSource::Pos(..) => None,
-        },
-        DocDef::Adt(it) => match it {
-            Adt::Struct(it) => docs_from_ast(&it.source(db).value),
-            Adt::Enum(it) => docs_from_ast(&it.source(db).value),
-            Adt::Union(it) => docs_from_ast(&it.source(db).value),
-        },
-        DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).value),
-        DocDef::Static(it) => docs_from_ast(&it.source(db).value),
-        DocDef::Const(it) => docs_from_ast(&it.source(db).value),
-        DocDef::Function(it) => docs_from_ast(&it.source(db).value),
-        DocDef::Trait(it) => docs_from_ast(&it.source(db).value),
-        DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).value),
-        DocDef::MacroDef(it) => docs_from_ast(&it.source(db).value),
-    }
-}
-
-impl<T: Into<DocDef> + Copy> Docs for T {
-    fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> {
-        db.documentation((*self).into())
-    }
-}
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index cae305f985..399101b835 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -5,7 +5,6 @@ use std::sync::Arc;
 use ra_db::salsa;
 
 use crate::{
-    debug::HirDebugDatabase,
     ids,
     ty::{
         method_resolution::CrateImplBlocks,
@@ -18,24 +17,16 @@ use crate::{
 
 pub use hir_def::db::{
     BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery,
-    DefDatabase2, DefDatabase2Storage, EnumDataQuery, ExprScopesQuery, FunctionDataQuery,
-    GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage, LangItemQuery,
-    ModuleLangItemsQuery, RawItemsQuery, RawItemsWithSourceMapQuery, StaticDataQuery,
-    StructDataQuery, TraitDataQuery, TypeAliasDataQuery,
+    DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery,
+    FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage,
+    LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, RawItemsWithSourceMapQuery,
+    StaticDataQuery, StructDataQuery, TraitDataQuery, TypeAliasDataQuery,
 };
 pub use hir_expand::db::{
     AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery,
     ParseMacroQuery,
 };
 
-// This database uses `AstDatabase` internally,
-#[salsa::query_group(DefDatabaseStorage)]
-#[salsa::requires(AstDatabase)]
-pub trait DefDatabase: HirDebugDatabase + DefDatabase2 {
-    #[salsa::invoke(crate::code_model::docs::documentation_query)]
-    fn documentation(&self, def: crate::DocDef) -> Option<crate::Documentation>;
-}
-
 #[salsa::query_group(HirDatabaseStorage)]
 #[salsa::requires(salsa::Database)]
 pub trait HirDatabase: DefDatabase + AstDatabase {
diff --git a/crates/ra_hir/src/debug.rs b/crates/ra_hir/src/debug.rs
index 4f3e922c3c..8ec371f6eb 100644
--- a/crates/ra_hir/src/debug.rs
+++ b/crates/ra_hir/src/debug.rs
@@ -1,3 +1,5 @@
+//! XXX: This does not work at the moment.
+//!
 //! printf debugging infrastructure for rust-analyzer.
 //!
 //! When you print a hir type, like a module, using `eprintln!("{:?}", module)`,
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs
index 5d7af00ab9..529ac82517 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/ra_hir/src/from_id.rs
@@ -4,14 +4,14 @@
 //! are splitting the hir.
 
 use hir_def::{
-    AdtId, AssocItemId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GenericDefId,
-    ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId,
+    AdtId, AssocItemId, AttrDefId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
+    GenericDefId, ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId,
 };
 
 use crate::{
     ty::{CallableDef, TypableDef},
-    Adt, AssocItem, Const, Crate, DefWithBody, EnumVariant, Function, GenericDef, ModuleDef,
-    Static, StructField, TypeAlias, VariantDef,
+    Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function, GenericDef,
+    ModuleDef, Static, StructField, TypeAlias, VariantDef,
 };
 
 impl From<ra_db::CrateId> for Crate {
@@ -240,3 +240,20 @@ impl From<StructField> for StructFieldId {
         StructFieldId { parent: def.parent.into(), local_id: def.id }
     }
 }
+
+impl From<AttrDef> for AttrDefId {
+    fn from(def: AttrDef) -> Self {
+        match def {
+            AttrDef::Module(it) => AttrDefId::ModuleId(it.id),
+            AttrDef::StructField(it) => AttrDefId::StructFieldId(it.into()),
+            AttrDef::Adt(it) => AttrDefId::AdtId(it.into()),
+            AttrDef::Function(it) => AttrDefId::FunctionId(it.id),
+            AttrDef::EnumVariant(it) => AttrDefId::EnumVariantId(it.into()),
+            AttrDef::Static(it) => AttrDefId::StaticId(it.id),
+            AttrDef::Const(it) => AttrDefId::ConstId(it.id),
+            AttrDef::Trait(it) => AttrDefId::TraitId(it.id),
+            AttrDef::TypeAlias(it) => AttrDefId::TypeAliasId(it.id),
+            AttrDef::MacroDef(it) => AttrDefId::MacroDefId(it.id),
+        }
+    }
+}
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 22da05a970..868df5b6b4 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -50,9 +50,8 @@ mod marks;
 
 pub use crate::{
     code_model::{
-        docs::{DocDef, Docs, Documentation},
         src::{HasBodySource, HasSource},
-        Adt, AssocItem, AttrDef, Const, Container, Crate, CrateDependency, DefWithBody, Enum,
+        Adt, AssocItem, AttrDef, Const, Container, Crate, CrateDependency, DefWithBody, Docs, Enum,
         EnumVariant, FieldSource, Function, GenericDef, GenericParam, HasAttrs, HasBody, ImplBlock,
         Local, MacroDef, Module, ModuleDef, ModuleSource, ScopeDef, Static, Struct, StructField,
         Trait, TypeAlias, Union, VariantDef,
@@ -70,6 +69,7 @@ pub use crate::{
 
 pub use hir_def::{
     builtin_type::BuiltinType,
+    docs::Documentation,
     nameres::{per_ns::PerNs, raw::ImportId},
     path::{Path, PathKind},
     type_ref::Mutability,
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index ae99afe396..20e9a1eb51 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -11,7 +11,7 @@ use ra_arena::{map::ArenaMap, Arena};
 use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
 
 use crate::{
-    db::DefDatabase2, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource,
+    db::DefDatabase, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource,
     LocalEnumVariantId, LocalStructFieldId, StructOrUnionId, VariantId,
 };
 
@@ -49,10 +49,7 @@ pub struct StructFieldData {
 }
 
 impl StructData {
-    pub(crate) fn struct_data_query(
-        db: &impl DefDatabase2,
-        id: StructOrUnionId,
-    ) -> Arc<StructData> {
+    pub(crate) fn struct_data_query(db: &impl DefDatabase, id: StructOrUnionId) -> Arc<StructData> {
         let src = id.source(db);
         let name = src.value.name().map(|n| n.as_name());
         let variant_data = VariantData::new(src.value.kind());
@@ -62,7 +59,7 @@ impl StructData {
 }
 
 impl EnumData {
-    pub(crate) fn enum_data_query(db: &impl DefDatabase2, e: EnumId) -> Arc<EnumData> {
+    pub(crate) fn enum_data_query(db: &impl DefDatabase, e: EnumId) -> Arc<EnumData> {
         let src = e.source(db);
         let name = src.value.name().map(|n| n.as_name());
         let mut trace = Trace::new_for_arena();
@@ -79,7 +76,7 @@ impl EnumData {
 impl HasChildSource for EnumId {
     type ChildId = LocalEnumVariantId;
     type Value = ast::EnumVariant;
-    fn child_source(&self, db: &impl DefDatabase2) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
+    fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
         let src = self.source(db);
         let mut trace = Trace::new_for_map();
         lower_enum(&mut trace, &src.value);
@@ -124,7 +121,7 @@ impl HasChildSource for VariantId {
     type ChildId = LocalStructFieldId;
     type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>;
 
-    fn child_source(&self, db: &impl DefDatabase2) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
+    fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> {
         let src = match self {
             VariantId::EnumVariantId(it) => {
                 // I don't really like the fact that we call into parent source
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs
index eee5e44bf9..48ce8cd936 100644
--- a/crates/ra_hir_def/src/attr.rs
+++ b/crates/ra_hir_def/src/attr.rs
@@ -12,7 +12,7 @@ use ra_syntax::{
 use tt::Subtree;
 
 use crate::{
-    db::DefDatabase2, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup,
+    db::DefDatabase, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup,
 };
 
 #[derive(Default, Debug, Clone, PartialEq, Eq)]
@@ -32,7 +32,7 @@ impl ops::Deref for Attrs {
 }
 
 impl Attrs {
-    pub(crate) fn attrs_query(db: &impl DefDatabase2, def: AttrDefId) -> Attrs {
+    pub(crate) fn attrs_query(db: &impl DefDatabase, def: AttrDefId) -> Attrs {
         match def {
             AttrDefId::ModuleId(module) => {
                 let def_map = db.crate_def_map(module.krate);
@@ -162,7 +162,7 @@ impl Attr {
 fn attrs_from_ast<D, N>(src: AstId<N>, db: &D) -> Attrs
 where
     N: ast::AttrsOwner,
-    D: DefDatabase2,
+    D: DefDatabase,
 {
     let hygiene = Hygiene::new(db, src.file_id());
     Attr::from_attrs_owner(&src.to_node(db), &hygiene)
@@ -172,7 +172,7 @@ fn attrs_from_loc<T, D>(node: T, db: &D) -> Attrs
 where
     T: HasSource,
     T::Value: ast::AttrsOwner,
-    D: DefDatabase2,
+    D: DefDatabase,
 {
     let src = node.source(db);
     let hygiene = Hygiene::new(db, src.file_id);
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index dfb79a30ac..225638b422 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -13,7 +13,7 @@ use ra_syntax::{ast, AstNode, AstPtr};
 use rustc_hash::FxHashMap;
 
 use crate::{
-    db::DefDatabase2,
+    db::DefDatabase,
     expr::{Expr, ExprId, Pat, PatId},
     nameres::CrateDefMap,
     path::Path,
@@ -28,7 +28,7 @@ pub struct Expander {
 }
 
 impl Expander {
-    pub fn new(db: &impl DefDatabase2, current_file_id: HirFileId, module: ModuleId) -> Expander {
+    pub fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander {
         let crate_def_map = db.crate_def_map(module.krate);
         let hygiene = Hygiene::new(db, current_file_id);
         Expander { crate_def_map, current_file_id, hygiene, module }
@@ -36,7 +36,7 @@ impl Expander {
 
     fn enter_expand(
         &mut self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         macro_call: ast::MacroCall,
     ) -> Option<(Mark, ast::Expr)> {
         let ast_id = AstId::new(
@@ -67,7 +67,7 @@ impl Expander {
         None
     }
 
-    fn exit(&mut self, db: &impl DefDatabase2, mark: Mark) {
+    fn exit(&mut self, db: &impl DefDatabase, mark: Mark) {
         self.hygiene = Hygiene::new(db, mark.file_id);
         self.current_file_id = mark.file_id;
         std::mem::forget(mark);
@@ -81,7 +81,7 @@ impl Expander {
         Path::from_src(path, &self.hygiene)
     }
 
-    fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
+    fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
         self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros()
     }
 }
@@ -142,7 +142,7 @@ pub struct BodySourceMap {
 
 impl Body {
     pub(crate) fn body_with_source_map_query(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         def: DefWithBodyId,
     ) -> (Arc<Body>, Arc<BodySourceMap>) {
         let mut params = None;
@@ -169,12 +169,12 @@ impl Body {
         (Arc::new(body), Arc::new(source_map))
     }
 
-    pub(crate) fn body_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<Body> {
+    pub(crate) fn body_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<Body> {
         db.body_with_source_map(def).0
     }
 
     fn new(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         expander: Expander,
         params: Option<ast::ParamList>,
         body: Option<ast::Expr>,
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index d8e911aa52..f4640dfa4f 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -17,7 +17,7 @@ use test_utils::tested_by;
 use crate::{
     body::{Body, BodySourceMap, Expander, PatPtr},
     builtin_type::{BuiltinFloat, BuiltinInt},
-    db::DefDatabase2,
+    db::DefDatabase,
     expr::{
         ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp,
         MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement,
@@ -28,7 +28,7 @@ use crate::{
 };
 
 pub(super) fn lower(
-    db: &impl DefDatabase2,
+    db: &impl DefDatabase,
     expander: Expander,
     params: Option<ast::ParamList>,
     body: Option<ast::Expr>,
@@ -57,7 +57,7 @@ struct ExprCollector<DB> {
 
 impl<'a, DB> ExprCollector<&'a DB>
 where
-    DB: DefDatabase2,
+    DB: DefDatabase,
 {
     fn collect(
         mut self,
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs
index 58740b679d..20d707bc42 100644
--- a/crates/ra_hir_def/src/body/scope.rs
+++ b/crates/ra_hir_def/src/body/scope.rs
@@ -7,7 +7,7 @@ use rustc_hash::FxHashMap;
 
 use crate::{
     body::Body,
-    db::DefDatabase2,
+    db::DefDatabase,
     expr::{Expr, ExprId, Pat, PatId, Statement},
     DefWithBodyId,
 };
@@ -45,7 +45,7 @@ pub struct ScopeData {
 }
 
 impl ExprScopes {
-    pub(crate) fn expr_scopes_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<ExprScopes> {
+    pub(crate) fn expr_scopes_query(db: &impl DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> {
         let body = db.body(def);
         Arc::new(ExprScopes::new(&*body))
     }
@@ -176,7 +176,7 @@ mod tests {
     use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
     use test_utils::{assert_eq_text, covers, extract_offset};
 
-    use crate::{db::DefDatabase2, test_db::TestDB, FunctionId, ModuleDefId};
+    use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
 
     fn find_function(db: &TestDB, file_id: FileId) -> FunctionId {
         let krate = db.test_crate();
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 91bac7415a..f0b3e198a3 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -9,7 +9,7 @@ use hir_expand::{
 use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
 
 use crate::{
-    db::DefDatabase2,
+    db::DefDatabase,
     type_ref::{Mutability, TypeRef},
     AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, HasSource,
     ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc,
@@ -26,7 +26,7 @@ pub struct FunctionData {
 }
 
 impl FunctionData {
-    pub(crate) fn fn_data_query(db: &impl DefDatabase2, func: FunctionId) -> Arc<FunctionData> {
+    pub(crate) fn fn_data_query(db: &impl DefDatabase, func: FunctionId) -> Arc<FunctionData> {
         let src = func.lookup(db).source(db);
         let name = src.value.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
         let mut params = Vec::new();
@@ -74,7 +74,7 @@ pub struct TypeAliasData {
 
 impl TypeAliasData {
     pub(crate) fn type_alias_data_query(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         typ: TypeAliasId,
     ) -> Arc<TypeAliasData> {
         let node = typ.lookup(db).source(db).value;
@@ -92,7 +92,7 @@ pub struct TraitData {
 }
 
 impl TraitData {
-    pub(crate) fn trait_data_query(db: &impl DefDatabase2, tr: TraitId) -> Arc<TraitData> {
+    pub(crate) fn trait_data_query(db: &impl DefDatabase, tr: TraitId) -> Arc<TraitData> {
         let src = tr.source(db);
         let name = src.value.name().map(|n| n.as_name());
         let auto = src.value.is_auto();
@@ -144,7 +144,7 @@ pub struct ImplData {
 }
 
 impl ImplData {
-    pub(crate) fn impl_data_query(db: &impl DefDatabase2, id: ImplId) -> Arc<ImplData> {
+    pub(crate) fn impl_data_query(db: &impl DefDatabase, id: ImplId) -> Arc<ImplData> {
         let src = id.source(db);
         let items = db.ast_id_map(src.file_id);
 
@@ -198,12 +198,12 @@ pub struct ConstData {
 }
 
 impl ConstData {
-    pub(crate) fn const_data_query(db: &impl DefDatabase2, konst: ConstId) -> Arc<ConstData> {
+    pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> {
         let node = konst.lookup(db).source(db).value;
         const_data_for(&node)
     }
 
-    pub(crate) fn static_data_query(db: &impl DefDatabase2, konst: StaticId) -> Arc<ConstData> {
+    pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> {
         let node = konst.source(db).value;
         const_data_for(&node)
     }
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs
index e87bd525a3..cf3a6ccd83 100644
--- a/crates/ra_hir_def/src/db.rs
+++ b/crates/ra_hir_def/src/db.rs
@@ -10,6 +10,7 @@ use crate::{
     attr::Attrs,
     body::{scope::ExprScopes, Body, BodySourceMap},
     data::{ConstData, FunctionData, ImplData, TraitData, TypeAliasData},
+    docs::Documentation,
     generics::GenericParams,
     lang_item::{LangItemTarget, LangItems},
     nameres::{
@@ -40,8 +41,8 @@ pub trait InternDatabase: SourceDatabase {
     fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> crate::ImplId;
 }
 
-#[salsa::query_group(DefDatabase2Storage)]
-pub trait DefDatabase2: InternDatabase + AstDatabase {
+#[salsa::query_group(DefDatabaseStorage)]
+pub trait DefDatabase: InternDatabase + AstDatabase {
     #[salsa::invoke(RawItems::raw_items_with_source_map_query)]
     fn raw_items_with_source_map(
         &self,
@@ -101,4 +102,9 @@ pub trait DefDatabase2: InternDatabase + AstDatabase {
 
     #[salsa::invoke(LangItems::lang_item_query)]
     fn lang_item(&self, start_crate: CrateId, item: SmolStr) -> Option<LangItemTarget>;
+
+    // FIXME(https://github.com/rust-analyzer/rust-analyzer/issues/2148#issuecomment-550519102)
+    // Remove this query completely, in favor of `Attrs::docs` method
+    #[salsa::invoke(Documentation::documentation_query)]
+    fn documentation(&self, def: AttrDefId) -> Option<Documentation>;
 }
diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs
new file mode 100644
index 0000000000..69846fd1b2
--- /dev/null
+++ b/crates/ra_hir_def/src/docs.rs
@@ -0,0 +1,68 @@
+//! FIXME: write short doc here
+
+use std::sync::Arc;
+
+use hir_expand::either::Either;
+use ra_syntax::ast;
+
+use crate::{db::DefDatabase, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup};
+
+/// Holds documentation
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Documentation(Arc<str>);
+
+impl Into<String> for Documentation {
+    fn into(self) -> String {
+        self.as_str().to_owned()
+    }
+}
+
+impl Documentation {
+    fn new(s: &str) -> Documentation {
+        Documentation(s.into())
+    }
+
+    pub fn as_str(&self) -> &str {
+        &*self.0
+    }
+
+    pub(crate) fn documentation_query(
+        db: &impl DefDatabase,
+        def: AttrDefId,
+    ) -> Option<Documentation> {
+        match def {
+            AttrDefId::ModuleId(module) => {
+                let def_map = db.crate_def_map(module.krate);
+                let src = def_map[module.module_id].declaration_source(db)?;
+                docs_from_ast(&src.value)
+            }
+            AttrDefId::StructFieldId(it) => {
+                let src = it.parent.child_source(db);
+                match &src.value[it.local_id] {
+                    Either::A(_tuple) => None,
+                    Either::B(record) => docs_from_ast(record),
+                }
+            }
+            AttrDefId::AdtId(it) => match it {
+                AdtId::StructId(it) => docs_from_ast(&it.0.source(db).value),
+                AdtId::EnumId(it) => docs_from_ast(&it.source(db).value),
+                AdtId::UnionId(it) => docs_from_ast(&it.0.source(db).value),
+            },
+            AttrDefId::EnumVariantId(it) => {
+                let src = it.parent.child_source(db);
+                docs_from_ast(&src.value[it.local_id])
+            }
+            AttrDefId::StaticId(it) => docs_from_ast(&it.source(db).value),
+            AttrDefId::TraitId(it) => docs_from_ast(&it.source(db).value),
+            AttrDefId::MacroDefId(it) => docs_from_ast(&it.ast_id.to_node(db)),
+            AttrDefId::ConstId(it) => docs_from_ast(&it.lookup(db).source(db).value),
+            AttrDefId::FunctionId(it) => docs_from_ast(&it.lookup(db).source(db).value),
+            AttrDefId::TypeAliasId(it) => docs_from_ast(&it.lookup(db).source(db).value),
+            AttrDefId::ImplId(_) => None,
+        }
+    }
+}
+
+pub(crate) fn docs_from_ast(node: &impl ast::DocCommentsOwner) -> Option<Documentation> {
+    node.doc_comment_text().map(|it| Documentation::new(&it))
+}
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 9e2e4c3cc3..015fe772e5 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -8,7 +8,7 @@ use hir_expand::name::{self, AsName, Name};
 use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner};
 
 use crate::{
-    db::DefDatabase2,
+    db::DefDatabase,
     type_ref::{TypeBound, TypeRef},
     AdtId, AstItemDef, ContainerId, GenericDefId, HasSource, Lookup,
 };
@@ -42,7 +42,7 @@ pub struct WherePredicate {
 
 impl GenericParams {
     pub(crate) fn generic_params_query(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         def: GenericDefId,
     ) -> Arc<GenericParams> {
         let parent_generics = parent_generic_def(db, def).map(|it| db.generic_params(it));
@@ -50,7 +50,7 @@ impl GenericParams {
     }
 
     fn new(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         def: GenericDefId,
         parent_params: Option<Arc<GenericParams>>,
     ) -> GenericParams {
@@ -168,7 +168,7 @@ impl GenericParams {
     }
 }
 
-fn parent_generic_def(db: &impl DefDatabase2, def: GenericDefId) -> Option<GenericDefId> {
+fn parent_generic_def(db: &impl DefDatabase, def: GenericDefId) -> Option<GenericDefId> {
     let container = match def {
         GenericDefId::FunctionId(it) => it.lookup(db).container,
         GenericDefId::TypeAliasId(it) => it.lookup(db).container,
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs
index 4c1a764ea0..df951c5330 100644
--- a/crates/ra_hir_def/src/lang_item.rs
+++ b/crates/ra_hir_def/src/lang_item.rs
@@ -8,7 +8,7 @@ use ra_syntax::SmolStr;
 use rustc_hash::FxHashMap;
 
 use crate::{
-    db::DefDatabase2, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId,
+    db::DefDatabase, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId,
     StaticId, StructId, TraitId,
 };
 
@@ -33,7 +33,7 @@ impl LangItems {
     }
 
     /// Salsa query. This will look for lang items in a specific crate.
-    pub(crate) fn crate_lang_items_query(db: &impl DefDatabase2, krate: CrateId) -> Arc<LangItems> {
+    pub(crate) fn crate_lang_items_query(db: &impl DefDatabase, krate: CrateId) -> Arc<LangItems> {
         let mut lang_items = LangItems::default();
 
         let crate_def_map = db.crate_def_map(krate);
@@ -47,7 +47,7 @@ impl LangItems {
     }
 
     pub(crate) fn module_lang_items_query(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         module: ModuleId,
     ) -> Option<Arc<LangItems>> {
         let mut lang_items = LangItems::default();
@@ -62,7 +62,7 @@ impl LangItems {
     /// Salsa query. Look for a lang item, starting from the specified crate and recursively
     /// traversing its dependencies.
     pub(crate) fn lang_item_query(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         start_crate: CrateId,
         item: SmolStr,
     ) -> Option<LangItemTarget> {
@@ -76,7 +76,7 @@ impl LangItems {
             .find_map(|dep| db.lang_item(dep.crate_id, item.clone()))
     }
 
-    fn collect_lang_items(&mut self, db: &impl DefDatabase2, module: ModuleId) {
+    fn collect_lang_items(&mut self, db: &impl DefDatabase, module: ModuleId) {
         // Look for impl targets
         let def_map = db.crate_def_map(module.krate);
         let module_data = &def_map[module.module_id];
@@ -106,7 +106,7 @@ impl LangItems {
 
     fn collect_lang_item<T>(
         &mut self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         item: T,
         constructor: fn(T) -> LangItemTarget,
     ) where
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 899510be4b..1b2bc6f45e 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -20,6 +20,7 @@ pub mod generics;
 pub mod resolver;
 pub mod data;
 pub mod lang_item;
+pub mod docs;
 
 mod trace;
 
@@ -47,7 +48,7 @@ pub enum ModuleSource {
 
 impl ModuleSource {
     pub fn new(
-        db: &impl db::DefDatabase2,
+        db: &impl db::DefDatabase,
         file_id: Option<FileId>,
         decl_id: Option<AstId<ast::Module>>,
     ) -> ModuleSource {
@@ -66,10 +67,7 @@ impl ModuleSource {
     }
 
     // FIXME: this methods do not belong here
-    pub fn from_position(
-        db: &impl db::DefDatabase2,
-        position: ra_db::FilePosition,
-    ) -> ModuleSource {
+    pub fn from_position(db: &impl db::DefDatabase, position: ra_db::FilePosition) -> ModuleSource {
         let parse = db.parse(position.file_id);
         match &ra_syntax::algo::find_node_at_offset::<ast::Module>(
             parse.tree().syntax(),
@@ -83,7 +81,7 @@ impl ModuleSource {
         }
     }
 
-    pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource {
+    pub fn from_child_node(db: &impl db::DefDatabase, child: Source<&SyntaxNode>) -> ModuleSource {
         if let Some(m) =
             child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
         {
@@ -95,7 +93,7 @@ impl ModuleSource {
         }
     }
 
-    pub fn from_file_id(db: &impl db::DefDatabase2, file_id: FileId) -> ModuleSource {
+    pub fn from_file_id(db: &impl db::DefDatabase, file_id: FileId) -> ModuleSource {
         let source_file = db.parse(file_id).tree();
         ModuleSource::SourceFile(source_file)
     }
@@ -210,14 +208,14 @@ pub struct FunctionLoc {
 
 impl Intern for FunctionLoc {
     type ID = FunctionId;
-    fn intern(self, db: &impl db::DefDatabase2) -> FunctionId {
+    fn intern(self, db: &impl db::DefDatabase) -> FunctionId {
         db.intern_function(self)
     }
 }
 
 impl Lookup for FunctionId {
     type Data = FunctionLoc;
-    fn lookup(&self, db: &impl db::DefDatabase2) -> FunctionLoc {
+    fn lookup(&self, db: &impl db::DefDatabase) -> FunctionLoc {
         db.lookup_intern_function(*self)
     }
 }
@@ -300,14 +298,14 @@ pub struct ConstLoc {
 
 impl Intern for ConstLoc {
     type ID = ConstId;
-    fn intern(self, db: &impl db::DefDatabase2) -> ConstId {
+    fn intern(self, db: &impl db::DefDatabase) -> ConstId {
         db.intern_const(self)
     }
 }
 
 impl Lookup for ConstId {
     type Data = ConstLoc;
-    fn lookup(&self, db: &impl db::DefDatabase2) -> ConstLoc {
+    fn lookup(&self, db: &impl db::DefDatabase) -> ConstLoc {
         db.lookup_intern_const(*self)
     }
 }
@@ -348,14 +346,14 @@ pub struct TypeAliasLoc {
 
 impl Intern for TypeAliasLoc {
     type ID = TypeAliasId;
-    fn intern(self, db: &impl db::DefDatabase2) -> TypeAliasId {
+    fn intern(self, db: &impl db::DefDatabase) -> TypeAliasId {
         db.intern_type_alias(self)
     }
 }
 
 impl Lookup for TypeAliasId {
     type Data = TypeAliasLoc;
-    fn lookup(&self, db: &impl db::DefDatabase2) -> TypeAliasLoc {
+    fn lookup(&self, db: &impl db::DefDatabase) -> TypeAliasLoc {
         db.lookup_intern_type_alias(*self)
     }
 }
@@ -509,20 +507,20 @@ impl_froms!(
 
 trait Intern {
     type ID;
-    fn intern(self, db: &impl db::DefDatabase2) -> Self::ID;
+    fn intern(self, db: &impl db::DefDatabase) -> Self::ID;
 }
 
 pub trait Lookup {
     type Data;
-    fn lookup(&self, db: &impl db::DefDatabase2) -> Self::Data;
+    fn lookup(&self, db: &impl db::DefDatabase) -> Self::Data;
 }
 
 pub trait HasModule {
-    fn module(&self, db: &impl db::DefDatabase2) -> ModuleId;
+    fn module(&self, db: &impl db::DefDatabase) -> ModuleId;
 }
 
 impl HasModule for FunctionLoc {
-    fn module(&self, db: &impl db::DefDatabase2) -> ModuleId {
+    fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
         match self.container {
             ContainerId::ModuleId(it) => it,
             ContainerId::ImplId(it) => it.module(db),
@@ -532,7 +530,7 @@ impl HasModule for FunctionLoc {
 }
 
 impl HasModule for TypeAliasLoc {
-    fn module(&self, db: &impl db::DefDatabase2) -> ModuleId {
+    fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
         match self.container {
             ContainerId::ModuleId(it) => it,
             ContainerId::ImplId(it) => it.module(db),
@@ -542,7 +540,7 @@ impl HasModule for TypeAliasLoc {
 }
 
 impl HasModule for ConstLoc {
-    fn module(&self, db: &impl db::DefDatabase2) -> ModuleId {
+    fn module(&self, db: &impl db::DefDatabase) -> ModuleId {
         match self.container {
             ContainerId::ModuleId(it) => it,
             ContainerId::ImplId(it) => it.module(db),
@@ -553,13 +551,13 @@ impl HasModule for ConstLoc {
 
 pub trait HasSource {
     type Value;
-    fn source(&self, db: &impl db::DefDatabase2) -> Source<Self::Value>;
+    fn source(&self, db: &impl db::DefDatabase) -> Source<Self::Value>;
 }
 
 impl HasSource for FunctionLoc {
     type Value = ast::FnDef;
 
-    fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::FnDef> {
+    fn source(&self, db: &impl db::DefDatabase) -> Source<ast::FnDef> {
         let node = self.ast_id.to_node(db);
         Source::new(self.ast_id.file_id(), node)
     }
@@ -568,7 +566,7 @@ impl HasSource for FunctionLoc {
 impl HasSource for TypeAliasLoc {
     type Value = ast::TypeAliasDef;
 
-    fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::TypeAliasDef> {
+    fn source(&self, db: &impl db::DefDatabase) -> Source<ast::TypeAliasDef> {
         let node = self.ast_id.to_node(db);
         Source::new(self.ast_id.file_id(), node)
     }
@@ -577,7 +575,7 @@ impl HasSource for TypeAliasLoc {
 impl HasSource for ConstLoc {
     type Value = ast::ConstDef;
 
-    fn source(&self, db: &impl db::DefDatabase2) -> Source<ast::ConstDef> {
+    fn source(&self, db: &impl db::DefDatabase) -> Source<ast::ConstDef> {
         let node = self.ast_id.to_node(db);
         Source::new(self.ast_id.file_id(), node)
     }
@@ -588,6 +586,6 @@ pub trait HasChildSource {
     type Value;
     fn child_source(
         &self,
-        db: &impl db::DefDatabase2,
+        db: &impl db::DefDatabase,
     ) -> Source<ArenaMap<Self::ChildId, Self::Value>>;
 }
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 6723465a59..101203b7b5 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -71,7 +71,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
 
 use crate::{
     builtin_type::BuiltinType,
-    db::DefDatabase2,
+    db::DefDatabase,
     nameres::{
         diagnostics::DefDiagnostic, path_resolution::ResolveMode, per_ns::PerNs, raw::ImportId,
     },
@@ -220,7 +220,7 @@ impl CrateDefMap {
     pub(crate) fn crate_def_map_query(
         // Note that this doesn't have `+ AstDatabase`!
         // This gurantess that `CrateDefMap` is stable across reparses.
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         krate: CrateId,
     ) -> Arc<CrateDefMap> {
         let _p = profile("crate_def_map_query");
@@ -262,7 +262,7 @@ impl CrateDefMap {
 
     pub fn add_diagnostics(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         module: CrateModuleId,
         sink: &mut DiagnosticSink,
     ) {
@@ -271,7 +271,7 @@ impl CrateDefMap {
 
     pub fn resolve_path(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         original_module: CrateModuleId,
         path: &Path,
     ) -> (PerNs, Option<usize>) {
@@ -295,7 +295,7 @@ impl ModuleData {
     /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
     pub fn definition_source(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
     ) -> Source<Either<ast::SourceFile, ast::Module>> {
         if let Some(file_id) = self.definition {
             let sf = db.parse(file_id).tree();
@@ -307,7 +307,7 @@ impl ModuleData {
 
     /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
     /// `None` for the crate root.
-    pub fn declaration_source(&self, db: &impl DefDatabase2) -> Option<Source<ast::Module>> {
+    pub fn declaration_source(&self, db: &impl DefDatabase) -> Option<Source<ast::Module>> {
         let decl = self.declaration?;
         let value = decl.to_node(db);
         Some(Source { file_id: decl.file_id(), value })
@@ -319,7 +319,7 @@ mod diagnostics {
     use ra_db::RelativePathBuf;
     use ra_syntax::{ast, AstPtr};
 
-    use crate::{db::DefDatabase2, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId};
+    use crate::{db::DefDatabase, diagnostics::UnresolvedModule, nameres::CrateModuleId, AstId};
 
     #[derive(Debug, PartialEq, Eq)]
     pub(super) enum DefDiagnostic {
@@ -333,7 +333,7 @@ mod diagnostics {
     impl DefDiagnostic {
         pub(super) fn add_to(
             &self,
-            db: &impl DefDatabase2,
+            db: &impl DefDatabase,
             target_module: CrateModuleId,
             sink: &mut DiagnosticSink,
         ) {
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 7902293e8f..1894b072a9 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -13,7 +13,7 @@ use test_utils::tested_by;
 
 use crate::{
     attr::Attrs,
-    db::DefDatabase2,
+    db::DefDatabase,
     nameres::{
         diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint,
         per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode,
@@ -24,7 +24,7 @@ use crate::{
     StructOrUnionId, TraitId, TypeAliasLoc, UnionId,
 };
 
-pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap {
+pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
     let crate_graph = db.crate_graph();
 
     // populate external prelude
@@ -108,7 +108,7 @@ struct DefCollector<'a, DB> {
 
 impl<DB> DefCollector<'_, DB>
 where
-    DB: DefDatabase2,
+    DB: DefDatabase,
 {
     fn collect(&mut self) {
         let crate_graph = self.db.crate_graph();
@@ -530,7 +530,7 @@ struct ModCollector<'a, D> {
 
 impl<DB> ModCollector<'_, &'_ mut DefCollector<'_, DB>>
 where
-    DB: DefDatabase2,
+    DB: DefDatabase,
 {
     fn collect(&mut self, items: &[raw::RawItem]) {
         // Note: don't assert that inserted value is fresh: it's simply not true
@@ -798,12 +798,12 @@ mod tests {
     use ra_db::{fixture::WithFixture, SourceDatabase};
     use rustc_hash::FxHashSet;
 
-    use crate::{db::DefDatabase2, test_db::TestDB};
+    use crate::{db::DefDatabase, test_db::TestDB};
 
     use super::*;
 
     fn do_collect_defs(
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         def_map: CrateDefMap,
         monitor: MacroStackMonitor,
     ) -> CrateDefMap {
diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs
index b3b1379d02..14fb8ba3a7 100644
--- a/crates/ra_hir_def/src/nameres/mod_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs
@@ -3,7 +3,7 @@ use hir_expand::name::Name;
 use ra_db::{FileId, RelativePathBuf};
 use ra_syntax::SmolStr;
 
-use crate::{db::DefDatabase2, HirFileId};
+use crate::{db::DefDatabase, HirFileId};
 
 #[derive(Clone, Debug)]
 pub(super) struct ModDir {
@@ -40,7 +40,7 @@ impl ModDir {
 
     pub(super) fn resolve_declaration(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         file_id: HirFileId,
         name: &Name,
         attr_path: Option<&SmolStr>,
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs
index 95692f8261..102009ac70 100644
--- a/crates/ra_hir_def/src/nameres/path_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/path_resolution.rs
@@ -15,7 +15,7 @@ use ra_db::Edition;
 use test_utils::tested_by;
 
 use crate::{
-    db::DefDatabase2,
+    db::DefDatabase,
     nameres::{per_ns::PerNs, CrateDefMap},
     path::{Path, PathKind},
     AdtId, CrateModuleId, EnumVariantId, ModuleDefId, ModuleId,
@@ -63,7 +63,7 @@ impl CrateDefMap {
     // the result.
     pub(super) fn resolve_path_fp_with_macro(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         mode: ResolveMode,
         original_module: CrateModuleId,
         path: &Path,
@@ -216,7 +216,7 @@ impl CrateDefMap {
 
     fn resolve_name_in_module(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         module: CrateModuleId,
         name: &Name,
     ) -> PerNs {
@@ -243,7 +243,7 @@ impl CrateDefMap {
         from_crate_root.or(from_extern_prelude)
     }
 
-    fn resolve_in_prelude(&self, db: &impl DefDatabase2, name: &Name) -> PerNs {
+    fn resolve_in_prelude(&self, db: &impl DefDatabase, name: &Name) -> PerNs {
         if let Some(prelude) = self.prelude {
             let keep;
             let def_map = if prelude.krate == self.krate {
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 55a9634f8b..7618cb0596 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -18,7 +18,7 @@ use test_utils::tested_by;
 
 use crate::{
     attr::{Attr, Attrs},
-    db::DefDatabase2,
+    db::DefDatabase,
     path::Path,
     FileAstId, HirFileId, ModuleSource, Source,
 };
@@ -67,14 +67,14 @@ impl ImportSourceMap {
 
 impl RawItems {
     pub(crate) fn raw_items_query(
-        db: &(impl DefDatabase2 + AstDatabase),
+        db: &(impl DefDatabase + AstDatabase),
         file_id: HirFileId,
     ) -> Arc<RawItems> {
         db.raw_items_with_source_map(file_id).0
     }
 
     pub(crate) fn raw_items_with_source_map_query(
-        db: &(impl DefDatabase2 + AstDatabase),
+        db: &(impl DefDatabase + AstDatabase),
         file_id: HirFileId,
     ) -> (Arc<RawItems>, Arc<ImportSourceMap>) {
         let mut collector = RawItemsCollector {
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 7b5c3ec061..48a836a20e 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -11,7 +11,7 @@ use rustc_hash::FxHashSet;
 use crate::{
     body::scope::{ExprScopes, ScopeId},
     builtin_type::BuiltinType,
-    db::DefDatabase2,
+    db::DefDatabase,
     expr::{ExprId, PatId},
     generics::GenericParams,
     nameres::{per_ns::PerNs, CrateDefMap},
@@ -87,7 +87,7 @@ pub enum ValueNs {
 
 impl Resolver {
     /// Resolve known trait from std, like `std::futures::Future`
-    pub fn resolve_known_trait(&self, db: &impl DefDatabase2, path: &Path) -> Option<TraitId> {
+    pub fn resolve_known_trait(&self, db: &impl DefDatabase, path: &Path) -> Option<TraitId> {
         let res = self.resolve_module_path(db, path).take_types()?;
         match res {
             ModuleDefId::TraitId(it) => Some(it),
@@ -96,7 +96,7 @@ impl Resolver {
     }
 
     /// Resolve known struct from std, like `std::boxed::Box`
-    pub fn resolve_known_struct(&self, db: &impl DefDatabase2, path: &Path) -> Option<StructId> {
+    pub fn resolve_known_struct(&self, db: &impl DefDatabase, path: &Path) -> Option<StructId> {
         let res = self.resolve_module_path(db, path).take_types()?;
         match res {
             ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it),
@@ -105,7 +105,7 @@ impl Resolver {
     }
 
     /// Resolve known enum from std, like `std::result::Result`
-    pub fn resolve_known_enum(&self, db: &impl DefDatabase2, path: &Path) -> Option<EnumId> {
+    pub fn resolve_known_enum(&self, db: &impl DefDatabase, path: &Path) -> Option<EnumId> {
         let res = self.resolve_module_path(db, path).take_types()?;
         match res {
             ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it),
@@ -114,7 +114,7 @@ impl Resolver {
     }
 
     /// pub only for source-binder
-    pub fn resolve_module_path(&self, db: &impl DefDatabase2, path: &Path) -> PerNs {
+    pub fn resolve_module_path(&self, db: &impl DefDatabase, path: &Path) -> PerNs {
         let (item_map, module) = match self.module() {
             Some(it) => it,
             None => return PerNs::none(),
@@ -128,7 +128,7 @@ impl Resolver {
 
     pub fn resolve_path_in_type_ns(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         path: &Path,
     ) -> Option<(TypeNs, Option<usize>)> {
         if path.is_type_relative() {
@@ -184,7 +184,7 @@ impl Resolver {
 
     pub fn resolve_path_in_type_ns_fully(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         path: &Path,
     ) -> Option<TypeNs> {
         let (res, unresolved) = self.resolve_path_in_type_ns(db, path)?;
@@ -196,7 +196,7 @@ impl Resolver {
 
     pub fn resolve_path_in_value_ns<'p>(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         path: &'p Path,
     ) -> Option<ResolveValueResult> {
         if path.is_type_relative() {
@@ -296,7 +296,7 @@ impl Resolver {
 
     pub fn resolve_path_in_value_ns_fully(
         &self,
-        db: &impl DefDatabase2,
+        db: &impl DefDatabase,
         path: &Path,
     ) -> Option<ValueNs> {
         match self.resolve_path_in_value_ns(db, path)? {
@@ -305,18 +305,18 @@ impl Resolver {
         }
     }
 
-    pub fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option<MacroDefId> {
+    pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
         let (item_map, module) = self.module()?;
         item_map.resolve_path(db, module, path).0.get_macros()
     }
 
-    pub fn process_all_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) {
+    pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
         for scope in self.scopes.iter().rev() {
             scope.process_names(db, f);
         }
     }
 
-    pub fn traits_in_scope(&self, db: &impl DefDatabase2) -> FxHashSet<TraitId> {
+    pub fn traits_in_scope(&self, db: &impl DefDatabase) -> FxHashSet<TraitId> {
         let mut traits = FxHashSet::default();
         for scope in &self.scopes {
             if let Scope::ModuleScope(m) = scope {
@@ -378,7 +378,7 @@ pub enum ScopeDef {
 }
 
 impl Scope {
-    fn process_names(&self, db: &impl DefDatabase2, f: &mut dyn FnMut(Name, ScopeDef)) {
+    fn process_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
         match self {
             Scope::ModuleScope(m) => {
                 // FIXME: should we provide `self` here?
@@ -425,17 +425,13 @@ impl Scope {
 }
 
 // needs arbitrary_self_types to be a method... or maybe move to the def?
-pub fn resolver_for_expr(
-    db: &impl DefDatabase2,
-    owner: DefWithBodyId,
-    expr_id: ExprId,
-) -> Resolver {
+pub fn resolver_for_expr(db: &impl DefDatabase, owner: DefWithBodyId, expr_id: ExprId) -> Resolver {
     let scopes = db.expr_scopes(owner);
     resolver_for_scope(db, owner, scopes.scope_for(expr_id))
 }
 
 pub fn resolver_for_scope(
-    db: &impl DefDatabase2,
+    db: &impl DefDatabase,
     owner: DefWithBodyId,
     scope_id: Option<ScopeId>,
 ) -> Resolver {
@@ -454,7 +450,7 @@ impl Resolver {
         self
     }
 
-    fn push_generic_params_scope(self, db: &impl DefDatabase2, def: GenericDefId) -> Resolver {
+    fn push_generic_params_scope(self, db: &impl DefDatabase, def: GenericDefId) -> Resolver {
         let params = db.generic_params(def);
         if params.params.is_empty() {
             self
@@ -487,24 +483,24 @@ impl Resolver {
 
 pub trait HasResolver {
     /// Builds a resolver for type references inside this def.
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver;
+    fn resolver(self, db: &impl DefDatabase) -> Resolver;
 }
 
 impl HasResolver for ModuleId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         let def_map = db.crate_def_map(self.krate);
         Resolver::default().push_module_scope(def_map, self.module_id)
     }
 }
 
 impl HasResolver for TraitId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         self.module(db).resolver(db).push_generic_params_scope(db, self.into())
     }
 }
 
 impl<T: Into<AdtId>> HasResolver for T {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         let def = self.into();
         let module = match def {
             AdtId::StructId(it) => it.0.module(db),
@@ -520,13 +516,13 @@ impl<T: Into<AdtId>> HasResolver for T {
 }
 
 impl HasResolver for FunctionId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into())
     }
 }
 
 impl HasResolver for DefWithBodyId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         match self {
             DefWithBodyId::ConstId(c) => c.resolver(db),
             DefWithBodyId::FunctionId(f) => f.resolver(db),
@@ -536,25 +532,25 @@ impl HasResolver for DefWithBodyId {
 }
 
 impl HasResolver for ConstId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         self.lookup(db).container.resolver(db)
     }
 }
 
 impl HasResolver for StaticId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         self.module(db).resolver(db)
     }
 }
 
 impl HasResolver for TypeAliasId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         self.lookup(db).container.resolver(db).push_generic_params_scope(db, self.into())
     }
 }
 
 impl HasResolver for ContainerId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         match self {
             ContainerId::TraitId(it) => it.resolver(db),
             ContainerId::ImplId(it) => it.resolver(db),
@@ -564,7 +560,7 @@ impl HasResolver for ContainerId {
 }
 
 impl HasResolver for GenericDefId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         match self {
             GenericDefId::FunctionId(inner) => inner.resolver(db),
             GenericDefId::AdtId(adt) => adt.resolver(db),
@@ -578,7 +574,7 @@ impl HasResolver for GenericDefId {
 }
 
 impl HasResolver for ImplId {
-    fn resolver(self, db: &impl DefDatabase2) -> Resolver {
+    fn resolver(self, db: &impl DefDatabase) -> Resolver {
         self.module(db)
             .resolver(db)
             .push_generic_params_scope(db, self.into())
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index c96465b6a3..c2a9dcdd14 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -22,7 +22,6 @@ use crate::{
     hir::db::InternDatabaseStorage,
     hir::db::AstDatabaseStorage,
     hir::db::DefDatabaseStorage,
-    hir::db::DefDatabase2Storage,
     hir::db::HirDatabaseStorage
 )]
 #[derive(Debug)]
diff --git a/docs/user/README.md b/docs/user/README.md
index 913ecea18d..bfb1904492 100644
--- a/docs/user/README.md
+++ b/docs/user/README.md
@@ -132,11 +132,6 @@ to load path and require it in `init.el`
 
 ## Vim and NeoVim
 
-Neovim 0.5 has a built in language server. For a quick start configuration of
-rust-analyzer, use [neovim/nvim-lsp](https://github.com/neovim/nvim-lsp#rust_analyzer).
-Once `neovim/nvim-lsp` is installed, you can use `call nvim_lsp#setup("rust_analyzer", {})`
-or `lua require'nvim_lsp'.rust_analyzer.setup({})` to quickly get set up.
-
 * Install coc.nvim by following the instructions at [coc.nvim]
   - You will need nodejs installed.
   - You may want to include some of the sample vim configurations [from here][coc-vim-conf]


Test patch:
diff --git a/crates/ra_assists/src/test_db.rs b/crates/ra_assists/src/test_db.rs
index 5be7383edc..5f96c974bc 100644
--- a/crates/ra_assists/src/test_db.rs
+++ b/crates/ra_assists/src/test_db.rs
@@ -10,7 +10,6 @@ use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath
     hir::db::InternDatabaseStorage,
     hir::db::AstDatabaseStorage,
     hir::db::DefDatabaseStorage,
-    hir::db::DefDatabase2Storage,
     hir::db::HirDatabaseStorage
 )]
 #[derive(Debug, Default)]
diff --git a/crates/ra_hir/src/test_db.rs b/crates/ra_hir/src/test_db.rs
index 1caa2e8759..03c7ac1552 100644
--- a/crates/ra_hir/src/test_db.rs
+++ b/crates/ra_hir/src/test_db.rs
@@ -2,7 +2,7 @@
 
 use std::{panic, sync::Arc};
 
-use hir_def::{db::DefDatabase2, ModuleId};
+use hir_def::{db::DefDatabase, ModuleId};
 use hir_expand::diagnostics::DiagnosticSink;
 use parking_lot::Mutex;
 use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase};
@@ -15,7 +15,6 @@ use crate::{db, debug::HirDebugHelper};
     db::InternDatabaseStorage,
     db::AstDatabaseStorage,
     db::DefDatabaseStorage,
-    db::DefDatabase2Storage,
     db::HirDatabaseStorage
 )]
 #[derive(Debug, Default)]
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index 256f7d4be7..b5053ba20e 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -10,7 +10,7 @@ use insta::assert_snapshot;
 use ra_db::{fixture::WithFixture, SourceDatabase};
 use test_utils::covers;
 
-use crate::{db::DefDatabase2, nameres::*, test_db::TestDB, CrateModuleId};
+use crate::{db::DefDatabase, nameres::*, test_db::TestDB, CrateModuleId};
 
 fn def_map(fixtute: &str) -> String {
     let dm = compute_crate_def_map(fixtute);
diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/ra_hir_def/src/test_db.rs
index 8ee8e40d08..439e8a412b 100644
--- a/crates/ra_hir_def/src/test_db.rs
+++ b/crates/ra_hir_def/src/test_db.rs
@@ -12,7 +12,7 @@ use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath
     ra_db::SourceDatabaseStorage,
     hir_expand::db::AstDatabaseStorage,
     crate::db::InternDatabaseStorage,
-    crate::db::DefDatabase2Storage
+    crate::db::DefDatabaseStorage
 )]
 #[derive(Debug, Default)]
 pub struct TestDB {