aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-19 17:58:04 +0000
committerFlorian Diebold <[email protected]>2019-01-19 17:58:04 +0000
commit969f588025ab2c3224757e282ef78a546c4f56c4 (patch)
tree0f0059a98b6ac1e9cdba23524ed40e0095da62d3 /crates/ra_hir
parent9e4b5ecec4fa4f6a20bb4d47f09de602e9c29608 (diff)
Generics -> GenericParams
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model_api.rs22
-rw-r--r--crates/ra_hir/src/db.rs6
-rw-r--r--crates/ra_hir/src/generics.rs8
-rw-r--r--crates/ra_hir/src/mock.rs2
-rw-r--r--crates/ra_hir/src/ty.rs38
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs4
6 files changed, 40 insertions, 40 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 6c85e5939..88eda5ed0 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -12,7 +12,7 @@ use crate::{
12 expr::BodySyntaxMapping, 12 expr::BodySyntaxMapping,
13 ty::InferenceResult, 13 ty::InferenceResult,
14 adt::VariantData, 14 adt::VariantData,
15 generics::Generics, 15 generics::GenericParams,
16 code_model_impl::def_id_to_ast, 16 code_model_impl::def_id_to_ast,
17}; 17};
18 18
@@ -203,8 +203,8 @@ impl Struct {
203 def_id_to_ast(db, self.def_id) 203 def_id_to_ast(db, self.def_id)
204 } 204 }
205 205
206 pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> { 206 pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> {
207 db.generics(self.def_id) 207 db.generic_params(self.def_id)
208 } 208 }
209} 209}
210 210
@@ -234,8 +234,8 @@ impl Enum {
234 def_id_to_ast(db, self.def_id) 234 def_id_to_ast(db, self.def_id)
235 } 235 }
236 236
237 pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> { 237 pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> {
238 db.generics(self.def_id) 238 db.generic_params(self.def_id)
239 } 239 }
240} 240}
241 241
@@ -349,8 +349,8 @@ impl Function {
349 db.infer(self.def_id) 349 db.infer(self.def_id)
350 } 350 }
351 351
352 pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> { 352 pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> {
353 db.generics(self.def_id) 353 db.generic_params(self.def_id)
354 } 354 }
355} 355}
356 356
@@ -398,8 +398,8 @@ impl Trait {
398 def_id_to_ast(db, self.def_id) 398 def_id_to_ast(db, self.def_id)
399 } 399 }
400 400
401 pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> { 401 pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> {
402 db.generics(self.def_id) 402 db.generic_params(self.def_id)
403 } 403 }
404} 404}
405 405
@@ -417,7 +417,7 @@ impl Type {
417 def_id_to_ast(db, self.def_id) 417 def_id_to_ast(db, self.def_id)
418 } 418 }
419 419
420 pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> { 420 pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> {
421 db.generics(self.def_id) 421 db.generic_params(self.def_id)
422 } 422 }
423} 423}
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index 10e64f880..f383701d7 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -14,7 +14,7 @@ use crate::{
14 ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks}, 14 ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks},
15 adt::{StructData, EnumData, EnumVariantData}, 15 adt::{StructData, EnumData, EnumVariantData},
16 impl_block::ModuleImplBlocks, 16 impl_block::ModuleImplBlocks,
17 generics::Generics, 17 generics::GenericParams,
18}; 18};
19 19
20#[salsa::query_group] 20#[salsa::query_group]
@@ -102,8 +102,8 @@ pub trait HirDatabase:
102 #[salsa::invoke(crate::expr::body_syntax_mapping)] 102 #[salsa::invoke(crate::expr::body_syntax_mapping)]
103 fn body_syntax_mapping(&self, def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping>; 103 fn body_syntax_mapping(&self, def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping>;
104 104
105 #[salsa::invoke(crate::generics::Generics::generics_query)] 105 #[salsa::invoke(crate::generics::GenericParams::generic_params_query)]
106 fn generics(&self, def_id: DefId) -> Arc<Generics>; 106 fn generic_params(&self, def_id: DefId) -> Arc<GenericParams>;
107 107
108 #[salsa::invoke(crate::FnSignature::fn_signature_query)] 108 #[salsa::invoke(crate::FnSignature::fn_signature_query)]
109 fn fn_signature(&self, def_id: DefId) -> Arc<FnSignature>; 109 fn fn_signature(&self, def_id: DefId) -> Arc<FnSignature>;
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index cdabc0424..d8248ad49 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -18,14 +18,14 @@ pub struct GenericParam {
18 18
19/// Data about the generic parameters of a function, struct, impl, etc. 19/// Data about the generic parameters of a function, struct, impl, etc.
20#[derive(Clone, PartialEq, Eq, Debug, Default)] 20#[derive(Clone, PartialEq, Eq, Debug, Default)]
21pub struct Generics { 21pub struct GenericParams {
22 pub(crate) params: Vec<GenericParam>, 22 pub(crate) params: Vec<GenericParam>,
23} 23}
24 24
25impl Generics { 25impl GenericParams {
26 pub(crate) fn generics_query(db: &impl HirDatabase, def_id: DefId) -> Arc<Generics> { 26 pub(crate) fn generic_params_query(db: &impl HirDatabase, def_id: DefId) -> Arc<GenericParams> {
27 let (_file_id, node) = def_id.source(db); 27 let (_file_id, node) = def_id.source(db);
28 let mut generics = Generics::default(); 28 let mut generics = GenericParams::default();
29 if let Some(type_param_list) = node.children().find_map(TypeParamList::cast) { 29 if let Some(type_param_list) = node.children().find_map(TypeParamList::cast) {
30 for (idx, type_param) in type_param_list.type_params().enumerate() { 30 for (idx, type_param) in type_param_list.type_params().enumerate() {
31 let name = type_param 31 let name = type_param
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index d674db8e6..6e6f2f04b 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -243,7 +243,7 @@ salsa::database_storage! {
243 fn body_hir() for db::BodyHirQuery; 243 fn body_hir() for db::BodyHirQuery;
244 fn body_syntax_mapping() for db::BodySyntaxMappingQuery; 244 fn body_syntax_mapping() for db::BodySyntaxMappingQuery;
245 fn fn_signature() for db::FnSignatureQuery; 245 fn fn_signature() for db::FnSignatureQuery;
246 fn generics() for db::GenericsQuery; 246 fn generic_params() for db::GenericParamsQuery;
247 } 247 }
248 } 248 }
249} 249}
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 3608daae4..3170ed24e 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -37,7 +37,7 @@ use crate::{
37 type_ref::{TypeRef, Mutability}, 37 type_ref::{TypeRef, Mutability},
38 name::KnownName, 38 name::KnownName,
39 expr::{Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, FieldPat}, 39 expr::{Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, FieldPat},
40 generics::Generics, 40 generics::GenericParams,
41 path::GenericArg, 41 path::GenericArg,
42}; 42};
43 43
@@ -283,7 +283,7 @@ impl Ty {
283 // resolver architecture 283 // resolver architecture
284 module: &Module, 284 module: &Module,
285 impl_block: Option<&ImplBlock>, 285 impl_block: Option<&ImplBlock>,
286 generics: &Generics, 286 generics: &GenericParams,
287 type_ref: &TypeRef, 287 type_ref: &TypeRef,
288 ) -> Self { 288 ) -> Self {
289 match type_ref { 289 match type_ref {
@@ -335,7 +335,7 @@ impl Ty {
335 db: &impl HirDatabase, 335 db: &impl HirDatabase,
336 module: &Module, 336 module: &Module,
337 impl_block: Option<&ImplBlock>, 337 impl_block: Option<&ImplBlock>,
338 generics: &Generics, 338 generics: &GenericParams,
339 type_ref: Option<&TypeRef>, 339 type_ref: Option<&TypeRef>,
340 ) -> Self { 340 ) -> Self {
341 type_ref.map_or(Ty::Unknown, |t| { 341 type_ref.map_or(Ty::Unknown, |t| {
@@ -347,7 +347,7 @@ impl Ty {
347 db: &impl HirDatabase, 347 db: &impl HirDatabase,
348 module: &Module, 348 module: &Module,
349 impl_block: Option<&ImplBlock>, 349 impl_block: Option<&ImplBlock>,
350 generics: &Generics, 350 generics: &GenericParams,
351 path: &Path, 351 path: &Path,
352 ) -> Self { 352 ) -> Self {
353 if let Some(name) = path.as_ident() { 353 if let Some(name) = path.as_ident() {
@@ -357,7 +357,7 @@ impl Ty {
357 return Ty::Float(float_ty); 357 return Ty::Float(float_ty);
358 } else if name.as_known_name() == Some(KnownName::SelfType) { 358 } else if name.as_known_name() == Some(KnownName::SelfType) {
359 // TODO pass the impl block's generics? 359 // TODO pass the impl block's generics?
360 let generics = &Generics::default(); 360 let generics = &GenericParams::default();
361 return Ty::from_hir_opt( 361 return Ty::from_hir_opt(
362 db, 362 db,
363 module, 363 module,
@@ -397,7 +397,7 @@ impl Ty {
397 // the scope of the segment... 397 // the scope of the segment...
398 module: &Module, 398 module: &Module,
399 impl_block: Option<&ImplBlock>, 399 impl_block: Option<&ImplBlock>,
400 outer_generics: &Generics, 400 outer_generics: &GenericParams,
401 path: &Path, 401 path: &Path,
402 resolved: DefId, 402 resolved: DefId,
403 ) -> Substs { 403 ) -> Substs {
@@ -408,10 +408,10 @@ impl Ty {
408 .last() 408 .last()
409 .expect("path should have at least one segment"); 409 .expect("path should have at least one segment");
410 let (def_generics, segment) = match def { 410 let (def_generics, segment) = match def {
411 Def::Struct(s) => (s.generics(db), last), 411 Def::Struct(s) => (s.generic_params(db), last),
412 Def::Enum(e) => (e.generics(db), last), 412 Def::Enum(e) => (e.generic_params(db), last),
413 Def::Function(f) => (f.generics(db), last), 413 Def::Function(f) => (f.generic_params(db), last),
414 Def::Trait(t) => (t.generics(db), last), 414 Def::Trait(t) => (t.generic_params(db), last),
415 Def::EnumVariant(ev) => { 415 Def::EnumVariant(ev) => {
416 // the generic args for an enum variant may be either specified 416 // the generic args for an enum variant may be either specified
417 // on the segment referring to the enum, or on the segment 417 // on the segment referring to the enum, or on the segment
@@ -426,7 +426,7 @@ impl Ty {
426 // Option::None::<T> 426 // Option::None::<T>
427 last 427 last
428 }; 428 };
429 (ev.parent_enum(db).generics(db), segment) 429 (ev.parent_enum(db).generic_params(db), segment)
430 } 430 }
431 _ => return Substs::empty(), 431 _ => return Substs::empty(),
432 }; 432 };
@@ -607,7 +607,7 @@ fn type_for_fn(db: &impl HirDatabase, f: Function) -> Ty {
607 let signature = f.signature(db); 607 let signature = f.signature(db);
608 let module = f.module(db); 608 let module = f.module(db);
609 let impl_block = f.impl_block(db); 609 let impl_block = f.impl_block(db);
610 let generics = f.generics(db); 610 let generics = f.generic_params(db);
611 let input = signature 611 let input = signature
612 .params() 612 .params()
613 .iter() 613 .iter()
@@ -624,7 +624,7 @@ fn type_for_fn(db: &impl HirDatabase, f: Function) -> Ty {
624 Ty::FnPtr(Arc::new(sig)) 624 Ty::FnPtr(Arc::new(sig))
625} 625}
626 626
627fn make_substs(generics: &Generics) -> Substs { 627fn make_substs(generics: &GenericParams) -> Substs {
628 Substs( 628 Substs(
629 generics 629 generics
630 .params 630 .params
@@ -636,7 +636,7 @@ fn make_substs(generics: &Generics) -> Substs {
636} 636}
637 637
638fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty { 638fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty {
639 let generics = s.generics(db); 639 let generics = s.generic_params(db);
640 Ty::Adt { 640 Ty::Adt {
641 def_id: s.def_id(), 641 def_id: s.def_id(),
642 name: s.name(db).unwrap_or_else(Name::missing), 642 name: s.name(db).unwrap_or_else(Name::missing),
@@ -645,7 +645,7 @@ fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Ty {
645} 645}
646 646
647pub(crate) fn type_for_enum(db: &impl HirDatabase, s: Enum) -> Ty { 647pub(crate) fn type_for_enum(db: &impl HirDatabase, s: Enum) -> Ty {
648 let generics = s.generics(db); 648 let generics = s.generic_params(db);
649 Ty::Adt { 649 Ty::Adt {
650 def_id: s.def_id(), 650 def_id: s.def_id(),
651 name: s.name(db).unwrap_or_else(Name::missing), 651 name: s.name(db).unwrap_or_else(Name::missing),
@@ -684,8 +684,8 @@ pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Ty {
684pub(super) fn type_for_field(db: &impl HirDatabase, def_id: DefId, field: Name) -> Option<Ty> { 684pub(super) fn type_for_field(db: &impl HirDatabase, def_id: DefId, field: Name) -> Option<Ty> {
685 let def = def_id.resolve(db); 685 let def = def_id.resolve(db);
686 let (variant_data, generics) = match def { 686 let (variant_data, generics) = match def {
687 Def::Struct(s) => (s.variant_data(db), s.generics(db)), 687 Def::Struct(s) => (s.variant_data(db), s.generic_params(db)),
688 Def::EnumVariant(ev) => (ev.variant_data(db), ev.parent_enum(db).generics(db)), 688 Def::EnumVariant(ev) => (ev.variant_data(db), ev.parent_enum(db).generic_params(db)),
689 // TODO: unions 689 // TODO: unions
690 _ => panic!( 690 _ => panic!(
691 "trying to get type for field in non-struct/variant {:?}", 691 "trying to get type for field in non-struct/variant {:?}",
@@ -880,7 +880,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
880 880
881 fn make_ty(&mut self, type_ref: &TypeRef) -> Ty { 881 fn make_ty(&mut self, type_ref: &TypeRef) -> Ty {
882 // TODO provide generics of function 882 // TODO provide generics of function
883 let generics = Generics::default(); 883 let generics = GenericParams::default();
884 let ty = Ty::from_hir( 884 let ty = Ty::from_hir(
885 self.db, 885 self.db,
886 &self.module, 886 &self.module,
@@ -1075,7 +1075,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1075 }; 1075 };
1076 // TODO remove the duplication between here and `Ty::from_path`? 1076 // TODO remove the duplication between here and `Ty::from_path`?
1077 // TODO provide generics of function 1077 // TODO provide generics of function
1078 let generics = Generics::default(); 1078 let generics = GenericParams::default();
1079 let substs = Ty::substs_from_path( 1079 let substs = Ty::substs_from_path(
1080 self.db, 1080 self.db,
1081 &self.module, 1081 &self.module,
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 53b6d15a8..9f65c5fe1 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -11,7 +11,7 @@ use ra_db::SourceRootId;
11use crate::{ 11use crate::{
12 HirDatabase, DefId, module_tree::ModuleId, Module, Crate, Name, Function, 12 HirDatabase, DefId, module_tree::ModuleId, Module, Crate, Name, Function,
13 impl_block::{ImplId, ImplBlock, ImplItem}, 13 impl_block::{ImplId, ImplBlock, ImplItem},
14 generics::Generics 14 generics::GenericParams
15}; 15};
16use super::Ty; 16use super::Ty;
17 17
@@ -69,7 +69,7 @@ impl CrateImplBlocks {
69 // ignore for now 69 // ignore for now
70 } else { 70 } else {
71 // TODO provide generics of impl 71 // TODO provide generics of impl
72 let generics = Generics::default(); 72 let generics = GenericParams::default();
73 let target_ty = Ty::from_hir( 73 let target_ty = Ty::from_hir(
74 db, 74 db,
75 &module, 75 &module,