From c4512fadb1b332b13bb41b0aa8a28aa964664842 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 11 Jun 2019 17:54:51 +0300 Subject: remove inherent source impls --- crates/ra_assists/src/add_missing_impl_members.rs | 2 +- crates/ra_assists/src/fill_match_arms.rs | 2 +- crates/ra_hir/src/adt.rs | 2 +- crates/ra_hir/src/code_model.rs | 51 +--------------------- crates/ra_hir/src/docs.rs | 2 +- crates/ra_hir/src/expr.rs | 1 + crates/ra_hir/src/expr/validation.rs | 2 +- crates/ra_hir/src/generics.rs | 4 +- crates/ra_hir/src/traits.rs | 2 +- crates/ra_hir/src/ty/infer.rs | 2 +- crates/ra_hir/src/type_alias.rs | 2 +- crates/ra_ide_api/src/completion/presentation.rs | 2 +- .../ra_ide_api/src/display/function_signature.rs | 7 +-- crates/ra_ide_api/src/display/navigation_target.rs | 4 +- crates/ra_ide_api/src/hover.rs | 4 +- 15 files changed, 22 insertions(+), 67 deletions(-) diff --git a/crates/ra_assists/src/add_missing_impl_members.rs b/crates/ra_assists/src/add_missing_impl_members.rs index 046f53a8c..0e49b0401 100644 --- a/crates/ra_assists/src/add_missing_impl_members.rs +++ b/crates/ra_assists/src/add_missing_impl_members.rs @@ -1,6 +1,6 @@ use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}}; -use hir::db::HirDatabase; +use hir::{HasSource, db::HirDatabase}; use ra_syntax::{SmolStr, TreeArc}; use ra_syntax::ast::{self, AstNode, FnDef, ImplItem, ImplItemKind, NameOwner}; use ra_db::FilePosition; diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs index 0e08830d1..a7de6ae9f 100644 --- a/crates/ra_assists/src/fill_match_arms.rs +++ b/crates/ra_assists/src/fill_match_arms.rs @@ -1,7 +1,7 @@ use std::fmt::Write; use hir::{ - AdtDef, FieldSource, + AdtDef, FieldSource, HasSource, db::HirDatabase, }; use ra_syntax::ast::{self, AstNode}; diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 2b372333f..6b8604b3e 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs @@ -11,7 +11,7 @@ use ra_syntax::{ use crate::{ Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase, - HirDatabase, HirFileId, StructField, FieldSource, Source, + HirDatabase, HirFileId, StructField, FieldSource, Source, HasSource, type_ref::TypeRef, DefDatabase, }; diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 1a33127fa..282bd15de 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -355,10 +355,6 @@ impl StructField { self.parent.variant_data(db).fields().unwrap()[self.id].name.clone() } - pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source { - self.source_impl(db).into() - } - pub fn ty(&self, db: &impl HirDatabase) -> Ty { db.type_for_field(*self) } @@ -381,10 +377,6 @@ impl HasSource for Struct { } impl Struct { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl HirDatabase) -> Module { self.id.module(db) } @@ -446,10 +438,6 @@ impl HasSource for Union { } impl Union { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn name(self, db: &impl DefDatabase) -> Option { db.struct_data(Struct { id: self.id }).name.clone() } @@ -483,10 +471,6 @@ impl HasSource for Enum { } impl Enum { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl HirDatabase) -> Module { self.id.module(db) } @@ -537,12 +521,6 @@ impl HasSource for EnumVariant { } impl EnumVariant { - pub fn source( - &self, - db: &(impl DefDatabase + AstDatabase), - ) -> Source> { - self.source_impl(db) - } pub fn module(&self, db: &impl HirDatabase) -> Module { self.parent.module(db) } @@ -692,10 +670,6 @@ impl FnSignature { } impl Function { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl DefDatabase) -> Module { self.id.module(db) } @@ -778,10 +752,6 @@ impl HasSource for Const { } impl Const { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl DefDatabase) -> Module { self.id.module(db) } @@ -866,10 +836,6 @@ impl HasSource for Static { } impl Static { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl DefDatabase) -> Module { self.id.module(db) } @@ -902,10 +868,6 @@ impl HasSource for Trait { } impl Trait { - pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl DefDatabase) -> Module { self.id.module(db) } @@ -952,13 +914,6 @@ impl HasSource for TypeAlias { } impl TypeAlias { - pub fn source( - self, - db: &(impl DefDatabase + AstDatabase), - ) -> Source> { - self.id.source(db).into() - } - pub fn module(self, db: &impl DefDatabase) -> Module { self.id.module(db) } @@ -1015,11 +970,7 @@ impl HasSource for MacroDef { } } -impl MacroDef { - pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source> { - (self.id.0.file_id(), self.id.0.to_node(db)).into() - } -} +impl MacroDef {} pub enum Container { Trait(Trait), diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/docs.rs index 4db066c43..da2b9b854 100644 --- a/crates/ra_hir/src/docs.rs +++ b/crates/ra_hir/src/docs.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use ra_syntax::ast; use crate::{ - HirDatabase, DefDatabase, AstDatabase, + HirDatabase, DefDatabase, AstDatabase, HasSource, Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef, }; diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 48e597519..b1973d19d 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -11,6 +11,7 @@ use ra_syntax::{ use crate::{ Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, + HasSource, name::AsName, type_ref::{Mutability, TypeRef}, }; diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index ff5e5f68e..534fd482b 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs @@ -5,7 +5,7 @@ use ra_syntax::ast::{AstNode, StructLit}; use crate::{ expr::AstPtr, - HirDatabase, Function, Name, + HirDatabase, Function, Name, HasSource, diagnostics::{DiagnosticSink, MissingFields}, adt::AdtDef, Path, diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index 0b8bd5700..462b136b7 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs @@ -8,8 +8,10 @@ use std::sync::Arc; use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner}; use crate::{ + HasSource, + Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef, db::{HirDatabase, DefDatabase, AstDatabase}, - Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, path::Path, type_ref::TypeRef, AdtDef + path::Path, type_ref::TypeRef, }; /// Data about a generic parameter (to a function, struct, impl, ...). diff --git a/crates/ra_hir/src/traits.rs b/crates/ra_hir/src/traits.rs index 86dceb2e0..f2950e1b2 100644 --- a/crates/ra_hir/src/traits.rs +++ b/crates/ra_hir/src/traits.rs @@ -6,7 +6,7 @@ use rustc_hash::FxHashMap; use ra_syntax::ast::{self, NameOwner}; use crate::{ - Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, + Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource, ids::LocationCtx, name::AsName, }; diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index a534c2336..fef0f1d24 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -1415,7 +1415,7 @@ mod diagnostics { use crate::{ expr::ExprId, diagnostics::{DiagnosticSink, NoSuchField}, - HirDatabase, Function, + HirDatabase, Function, HasSource, }; #[derive(Debug, PartialEq, Eq, Clone)] diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs index c449d7346..87b9caa8a 100644 --- a/crates/ra_hir/src/type_alias.rs +++ b/crates/ra_hir/src/type_alias.rs @@ -2,7 +2,7 @@ use std::sync::Arc; -use crate::{TypeAlias, DefDatabase, AstDatabase, type_ref::TypeRef}; +use crate::{TypeAlias, DefDatabase, AstDatabase, HasSource, type_ref::TypeRef}; pub(crate) fn type_alias_ref_query( db: &(impl DefDatabase + AstDatabase), diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 495899262..f4ff4404b 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -1,7 +1,7 @@ //! This modules takes care of rendering various defenitions as completion items. use join_to_string::join; use test_utils::tested_by; -use hir::{Docs, PerNs, Resolution, HirDisplay}; +use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource}; use ra_syntax::ast::NameOwner; use crate::completion::{ diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs index d0c155de7..b0b0c7122 100644 --- a/crates/ra_ide_api/src/display/function_signature.rs +++ b/crates/ra_ide_api/src/display/function_signature.rs @@ -1,10 +1,11 @@ -use super::{where_predicates, generic_parameters}; -use crate::db; use std::fmt::{self, Display}; + use join_to_string::join; use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; use std::convert::From; -use hir::{Docs, Documentation}; +use hir::{Docs, Documentation, HasSource}; + +use crate::{db, display::{where_predicates, generic_parameters}}; /// Contains information about a function signature #[derive(Debug)] diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index d7687e1a4..1e9cdaff4 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -5,7 +5,7 @@ use ra_syntax::{ ast::{self, DocCommentsOwner}, algo::visit::{visitor, Visitor}, }; -use hir::{ModuleSource, FieldSource, ImplItem}; +use hir::{ModuleSource, FieldSource, ImplItem, HasSource}; use crate::{FileSymbol, db::RootDatabase}; use super::short_label::ShortLabel; @@ -182,7 +182,7 @@ impl NavigationTarget { pub(crate) fn from_def_source(db: &RootDatabase, def: D) -> NavigationTarget where - D: hir::HasSource>, + D: HasSource>, A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel, { let src = def.source(db); diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 77657607b..ad00abe49 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs @@ -4,7 +4,7 @@ use ra_syntax::{ ast::{self, DocCommentsOwner}, algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}}, }; -use hir::HirDisplay; +use hir::{HirDisplay, HasSource}; use crate::{ db::RootDatabase, @@ -226,7 +226,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option(db: &RootDatabase, def: D) -> Option where - D: hir::HasSource>, + D: HasSource>, A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel, { let src = def.source(db); -- cgit v1.2.3