aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/add_missing_impl_members.rs2
-rw-r--r--crates/ra_assists/src/fill_match_arms.rs2
-rw-r--r--crates/ra_hir/src/adt.rs2
-rw-r--r--crates/ra_hir/src/code_model.rs51
-rw-r--r--crates/ra_hir/src/docs.rs2
-rw-r--r--crates/ra_hir/src/expr.rs1
-rw-r--r--crates/ra_hir/src/expr/validation.rs2
-rw-r--r--crates/ra_hir/src/generics.rs4
-rw-r--r--crates/ra_hir/src/traits.rs2
-rw-r--r--crates/ra_hir/src/ty/infer.rs2
-rw-r--r--crates/ra_hir/src/type_alias.rs2
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs2
-rw-r--r--crates/ra_ide_api/src/display/function_signature.rs7
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs4
-rw-r--r--crates/ra_ide_api/src/hover.rs4
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 @@
1use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}}; 1use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}};
2 2
3use hir::db::HirDatabase; 3use hir::{HasSource, db::HirDatabase};
4use ra_syntax::{SmolStr, TreeArc}; 4use ra_syntax::{SmolStr, TreeArc};
5use ra_syntax::ast::{self, AstNode, FnDef, ImplItem, ImplItemKind, NameOwner}; 5use ra_syntax::ast::{self, AstNode, FnDef, ImplItem, ImplItemKind, NameOwner};
6use ra_db::FilePosition; 6use 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 @@
1use std::fmt::Write; 1use std::fmt::Write;
2 2
3use hir::{ 3use hir::{
4 AdtDef, FieldSource, 4 AdtDef, FieldSource, HasSource,
5 db::HirDatabase, 5 db::HirDatabase,
6}; 6};
7use ra_syntax::ast::{self, AstNode}; 7use 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::{
11 11
12use crate::{ 12use crate::{
13 Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase, 13 Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase,
14 HirDatabase, HirFileId, StructField, FieldSource, Source, 14 HirDatabase, HirFileId, StructField, FieldSource, Source, HasSource,
15 type_ref::TypeRef, DefDatabase, 15 type_ref::TypeRef, DefDatabase,
16}; 16};
17 17
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 {
355 self.parent.variant_data(db).fields().unwrap()[self.id].name.clone() 355 self.parent.variant_data(db).fields().unwrap()[self.id].name.clone()
356 } 356 }
357 357
358 pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<FieldSource> {
359 self.source_impl(db).into()
360 }
361
362 pub fn ty(&self, db: &impl HirDatabase) -> Ty { 358 pub fn ty(&self, db: &impl HirDatabase) -> Ty {
363 db.type_for_field(*self) 359 db.type_for_field(*self)
364 } 360 }
@@ -381,10 +377,6 @@ impl HasSource for Struct {
381} 377}
382 378
383impl Struct { 379impl Struct {
384 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StructDef>> {
385 self.id.source(db).into()
386 }
387
388 pub fn module(self, db: &impl HirDatabase) -> Module { 380 pub fn module(self, db: &impl HirDatabase) -> Module {
389 self.id.module(db) 381 self.id.module(db)
390 } 382 }
@@ -446,10 +438,6 @@ impl HasSource for Union {
446} 438}
447 439
448impl Union { 440impl Union {
449 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StructDef>> {
450 self.id.source(db).into()
451 }
452
453 pub fn name(self, db: &impl DefDatabase) -> Option<Name> { 441 pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
454 db.struct_data(Struct { id: self.id }).name.clone() 442 db.struct_data(Struct { id: self.id }).name.clone()
455 } 443 }
@@ -483,10 +471,6 @@ impl HasSource for Enum {
483} 471}
484 472
485impl Enum { 473impl Enum {
486 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::EnumDef>> {
487 self.id.source(db).into()
488 }
489
490 pub fn module(self, db: &impl HirDatabase) -> Module { 474 pub fn module(self, db: &impl HirDatabase) -> Module {
491 self.id.module(db) 475 self.id.module(db)
492 } 476 }
@@ -537,12 +521,6 @@ impl HasSource for EnumVariant {
537} 521}
538 522
539impl EnumVariant { 523impl EnumVariant {
540 pub fn source(
541 &self,
542 db: &(impl DefDatabase + AstDatabase),
543 ) -> Source<TreeArc<ast::EnumVariant>> {
544 self.source_impl(db)
545 }
546 pub fn module(&self, db: &impl HirDatabase) -> Module { 524 pub fn module(&self, db: &impl HirDatabase) -> Module {
547 self.parent.module(db) 525 self.parent.module(db)
548 } 526 }
@@ -692,10 +670,6 @@ impl FnSignature {
692} 670}
693 671
694impl Function { 672impl Function {
695 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::FnDef>> {
696 self.id.source(db).into()
697 }
698
699 pub fn module(self, db: &impl DefDatabase) -> Module { 673 pub fn module(self, db: &impl DefDatabase) -> Module {
700 self.id.module(db) 674 self.id.module(db)
701 } 675 }
@@ -778,10 +752,6 @@ impl HasSource for Const {
778} 752}
779 753
780impl Const { 754impl Const {
781 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::ConstDef>> {
782 self.id.source(db).into()
783 }
784
785 pub fn module(self, db: &impl DefDatabase) -> Module { 755 pub fn module(self, db: &impl DefDatabase) -> Module {
786 self.id.module(db) 756 self.id.module(db)
787 } 757 }
@@ -866,10 +836,6 @@ impl HasSource for Static {
866} 836}
867 837
868impl Static { 838impl Static {
869 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::StaticDef>> {
870 self.id.source(db).into()
871 }
872
873 pub fn module(self, db: &impl DefDatabase) -> Module { 839 pub fn module(self, db: &impl DefDatabase) -> Module {
874 self.id.module(db) 840 self.id.module(db)
875 } 841 }
@@ -902,10 +868,6 @@ impl HasSource for Trait {
902} 868}
903 869
904impl Trait { 870impl Trait {
905 pub fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::TraitDef>> {
906 self.id.source(db).into()
907 }
908
909 pub fn module(self, db: &impl DefDatabase) -> Module { 871 pub fn module(self, db: &impl DefDatabase) -> Module {
910 self.id.module(db) 872 self.id.module(db)
911 } 873 }
@@ -952,13 +914,6 @@ impl HasSource for TypeAlias {
952} 914}
953 915
954impl TypeAlias { 916impl TypeAlias {
955 pub fn source(
956 self,
957 db: &(impl DefDatabase + AstDatabase),
958 ) -> Source<TreeArc<ast::TypeAliasDef>> {
959 self.id.source(db).into()
960 }
961
962 pub fn module(self, db: &impl DefDatabase) -> Module { 917 pub fn module(self, db: &impl DefDatabase) -> Module {
963 self.id.module(db) 918 self.id.module(db)
964 } 919 }
@@ -1015,11 +970,7 @@ impl HasSource for MacroDef {
1015 } 970 }
1016} 971}
1017 972
1018impl MacroDef { 973impl MacroDef {}
1019 pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<TreeArc<ast::MacroCall>> {
1020 (self.id.0.file_id(), self.id.0.to_node(db)).into()
1021 }
1022}
1023 974
1024pub enum Container { 975pub enum Container {
1025 Trait(Trait), 976 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;
3use ra_syntax::ast; 3use ra_syntax::ast;
4 4
5use crate::{ 5use crate::{
6 HirDatabase, DefDatabase, AstDatabase, 6 HirDatabase, DefDatabase, AstDatabase, HasSource,
7 Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef, 7 Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef,
8}; 8};
9 9
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::{
11 11
12use crate::{ 12use crate::{
13 Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, 13 Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
14 HasSource,
14 name::AsName, 15 name::AsName,
15 type_ref::{Mutability, TypeRef}, 16 type_ref::{Mutability, TypeRef},
16}; 17};
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};
5 5
6use crate::{ 6use crate::{
7 expr::AstPtr, 7 expr::AstPtr,
8 HirDatabase, Function, Name, 8 HirDatabase, Function, Name, HasSource,
9 diagnostics::{DiagnosticSink, MissingFields}, 9 diagnostics::{DiagnosticSink, MissingFields},
10 adt::AdtDef, 10 adt::AdtDef,
11 Path, 11 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;
8use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner}; 8use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner};
9 9
10use crate::{ 10use crate::{
11 HasSource,
12 Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef,
11 db::{HirDatabase, DefDatabase, AstDatabase}, 13 db::{HirDatabase, DefDatabase, AstDatabase},
12 Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, path::Path, type_ref::TypeRef, AdtDef 14 path::Path, type_ref::TypeRef,
13}; 15};
14 16
15/// Data about a generic parameter (to a function, struct, impl, ...). 17/// 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;
6use ra_syntax::ast::{self, NameOwner}; 6use ra_syntax::ast::{self, NameOwner};
7 7
8use crate::{ 8use crate::{
9 Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, 9 Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource,
10 ids::LocationCtx, name::AsName, 10 ids::LocationCtx, name::AsName,
11}; 11};
12 12
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 {
1415 use crate::{ 1415 use crate::{
1416 expr::ExprId, 1416 expr::ExprId,
1417 diagnostics::{DiagnosticSink, NoSuchField}, 1417 diagnostics::{DiagnosticSink, NoSuchField},
1418 HirDatabase, Function, 1418 HirDatabase, Function, HasSource,
1419}; 1419};
1420 1420
1421 #[derive(Debug, PartialEq, Eq, Clone)] 1421 #[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 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use crate::{TypeAlias, DefDatabase, AstDatabase, type_ref::TypeRef}; 5use crate::{TypeAlias, DefDatabase, AstDatabase, HasSource, type_ref::TypeRef};
6 6
7pub(crate) fn type_alias_ref_query( 7pub(crate) fn type_alias_ref_query(
8 db: &(impl DefDatabase + AstDatabase), 8 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 @@
1//! This modules takes care of rendering various defenitions as completion items. 1//! This modules takes care of rendering various defenitions as completion items.
2use join_to_string::join; 2use join_to_string::join;
3use test_utils::tested_by; 3use test_utils::tested_by;
4use hir::{Docs, PerNs, Resolution, HirDisplay}; 4use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource};
5use ra_syntax::ast::NameOwner; 5use ra_syntax::ast::NameOwner;
6 6
7use crate::completion::{ 7use 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 @@
1use super::{where_predicates, generic_parameters};
2use crate::db;
3use std::fmt::{self, Display}; 1use std::fmt::{self, Display};
2
4use join_to_string::join; 3use join_to_string::join;
5use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; 4use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
6use std::convert::From; 5use std::convert::From;
7use hir::{Docs, Documentation}; 6use hir::{Docs, Documentation, HasSource};
7
8use crate::{db, display::{where_predicates, generic_parameters}};
8 9
9/// Contains information about a function signature 10/// Contains information about a function signature
10#[derive(Debug)] 11#[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::{
5 ast::{self, DocCommentsOwner}, 5 ast::{self, DocCommentsOwner},
6 algo::visit::{visitor, Visitor}, 6 algo::visit::{visitor, Visitor},
7}; 7};
8use hir::{ModuleSource, FieldSource, ImplItem}; 8use hir::{ModuleSource, FieldSource, ImplItem, HasSource};
9 9
10use crate::{FileSymbol, db::RootDatabase}; 10use crate::{FileSymbol, db::RootDatabase};
11use super::short_label::ShortLabel; 11use super::short_label::ShortLabel;
@@ -182,7 +182,7 @@ impl NavigationTarget {
182 182
183 pub(crate) fn from_def_source<A, D>(db: &RootDatabase, def: D) -> NavigationTarget 183 pub(crate) fn from_def_source<A, D>(db: &RootDatabase, def: D) -> NavigationTarget
184 where 184 where
185 D: hir::HasSource<Ast = TreeArc<A>>, 185 D: HasSource<Ast = TreeArc<A>>,
186 A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel, 186 A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel,
187 { 187 {
188 let src = def.source(db); 188 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::{
4 ast::{self, DocCommentsOwner}, 4 ast::{self, DocCommentsOwner},
5 algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}}, 5 algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}},
6}; 6};
7use hir::HirDisplay; 7use hir::{HirDisplay, HasSource};
8 8
9use crate::{ 9use crate::{
10 db::RootDatabase, 10 db::RootDatabase,
@@ -226,7 +226,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
226 226
227 fn from_def_source<A, D>(db: &RootDatabase, def: D) -> Option<String> 227 fn from_def_source<A, D>(db: &RootDatabase, def: D) -> Option<String>
228 where 228 where
229 D: hir::HasSource<Ast = TreeArc<A>>, 229 D: HasSource<Ast = TreeArc<A>>,
230 A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel, 230 A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel,
231 { 231 {
232 let src = def.source(db); 232 let src = def.source(db);