diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-19 10:54:16 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-19 10:54:16 +0100 |
commit | 09864b3b217e2ad6ca8630af6faaaefd8d14e860 (patch) | |
tree | b3a6258d9225027284a1a8ce6c47fb4d47bd9309 /crates/ra_hir/src/ty | |
parent | 78494b3c74c5c49e3352b3b65bd8b2d68f028d38 (diff) | |
parent | 0caec7d250affd042e51d035fb6d86c0f7f25f94 (diff) |
Merge #1418
1418: rename XSignature -> XData r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 25 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 8 |
3 files changed, 23 insertions, 25 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 1ee40c70a..2c05ca734 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -27,7 +27,7 @@ use ra_prof::profile; | |||
27 | use test_utils::tested_by; | 27 | use test_utils::tested_by; |
28 | 28 | ||
29 | use crate::{ | 29 | use crate::{ |
30 | Function, StructField, Path, Name, FnSignature, AdtDef, ConstSignature, HirDatabase, | 30 | Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase, |
31 | DefWithBody, ImplItem, | 31 | DefWithBody, ImplItem, |
32 | type_ref::{TypeRef, Mutability}, | 32 | type_ref::{TypeRef, Mutability}, |
33 | expr::{ | 33 | expr::{ |
@@ -59,9 +59,9 @@ pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResu | |||
59 | let mut ctx = InferenceContext::new(db, body, resolver); | 59 | let mut ctx = InferenceContext::new(db, body, resolver); |
60 | 60 | ||
61 | match def { | 61 | match def { |
62 | DefWithBody::Const(ref c) => ctx.collect_const_signature(&c.signature(db)), | 62 | DefWithBody::Const(ref c) => ctx.collect_const(&c.data(db)), |
63 | DefWithBody::Function(ref f) => ctx.collect_fn_signature(&f.signature(db)), | 63 | DefWithBody::Function(ref f) => ctx.collect_fn(&f.data(db)), |
64 | DefWithBody::Static(ref s) => ctx.collect_const_signature(&s.signature(db)), | 64 | DefWithBody::Static(ref s) => ctx.collect_const(&s.data(db)), |
65 | } | 65 | } |
66 | 66 | ||
67 | ctx.infer_body(); | 67 | ctx.infer_body(); |
@@ -509,8 +509,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
509 | let item: crate::ModuleDef = ty.iterate_impl_items(self.db, krate, |item| { | 509 | let item: crate::ModuleDef = ty.iterate_impl_items(self.db, krate, |item| { |
510 | let matching_def: Option<crate::ModuleDef> = match item { | 510 | let matching_def: Option<crate::ModuleDef> = match item { |
511 | crate::ImplItem::Method(func) => { | 511 | crate::ImplItem::Method(func) => { |
512 | let sig = func.signature(self.db); | 512 | if segment.name == func.name(self.db) { |
513 | if segment.name == *sig.name() { | ||
514 | Some(func.into()) | 513 | Some(func.into()) |
515 | } else { | 514 | } else { |
516 | None | 515 | None |
@@ -518,8 +517,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
518 | } | 517 | } |
519 | 518 | ||
520 | crate::ImplItem::Const(konst) => { | 519 | crate::ImplItem::Const(konst) => { |
521 | let sig = konst.signature(self.db); | 520 | let data = konst.data(self.db); |
522 | if segment.name == *sig.name() { | 521 | if segment.name == *data.name() { |
523 | Some(konst.into()) | 522 | Some(konst.into()) |
524 | } else { | 523 | } else { |
525 | None | 524 | None |
@@ -1283,18 +1282,18 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1283 | ty | 1282 | ty |
1284 | } | 1283 | } |
1285 | 1284 | ||
1286 | fn collect_const_signature(&mut self, signature: &ConstSignature) { | 1285 | fn collect_const(&mut self, data: &ConstData) { |
1287 | self.return_ty = self.make_ty(signature.type_ref()); | 1286 | self.return_ty = self.make_ty(data.type_ref()); |
1288 | } | 1287 | } |
1289 | 1288 | ||
1290 | fn collect_fn_signature(&mut self, signature: &FnSignature) { | 1289 | fn collect_fn(&mut self, data: &FnData) { |
1291 | let body = Arc::clone(&self.body); // avoid borrow checker problem | 1290 | let body = Arc::clone(&self.body); // avoid borrow checker problem |
1292 | for (type_ref, pat) in signature.params().iter().zip(body.params()) { | 1291 | for (type_ref, pat) in data.params().iter().zip(body.params()) { |
1293 | let ty = self.make_ty(type_ref); | 1292 | let ty = self.make_ty(type_ref); |
1294 | 1293 | ||
1295 | self.infer_pat(*pat, &ty, BindingMode::default()); | 1294 | self.infer_pat(*pat, &ty, BindingMode::default()); |
1296 | } | 1295 | } |
1297 | self.return_ty = self.make_ty(signature.ret_type()); | 1296 | self.return_ty = self.make_ty(data.ret_type()); |
1298 | } | 1297 | } |
1299 | 1298 | ||
1300 | fn infer_body(&mut self) { | 1299 | fn infer_body(&mut self) { |
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 300616a53..cb494baf4 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -353,11 +353,10 @@ pub(crate) fn generic_defaults(db: &impl HirDatabase, def: GenericDef) -> Substs | |||
353 | } | 353 | } |
354 | 354 | ||
355 | fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { | 355 | fn fn_sig_for_fn(db: &impl HirDatabase, def: Function) -> FnSig { |
356 | let signature = def.signature(db); | 356 | let data = def.data(db); |
357 | let resolver = def.resolver(db); | 357 | let resolver = def.resolver(db); |
358 | let params = | 358 | let params = data.params().iter().map(|tr| Ty::from_hir(db, &resolver, tr)).collect::<Vec<_>>(); |
359 | signature.params().iter().map(|tr| Ty::from_hir(db, &resolver, tr)).collect::<Vec<_>>(); | 359 | let ret = Ty::from_hir(db, &resolver, data.ret_type()); |
360 | let ret = Ty::from_hir(db, &resolver, signature.ret_type()); | ||
361 | FnSig::from_params_and_return(params, ret) | 360 | FnSig::from_params_and_return(params, ret) |
362 | } | 361 | } |
363 | 362 | ||
@@ -371,18 +370,18 @@ fn type_for_fn(db: &impl HirDatabase, def: Function) -> Ty { | |||
371 | 370 | ||
372 | /// Build the declared type of a const. | 371 | /// Build the declared type of a const. |
373 | fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { | 372 | fn type_for_const(db: &impl HirDatabase, def: Const) -> Ty { |
374 | let signature = def.signature(db); | 373 | let data = def.data(db); |
375 | let resolver = def.resolver(db); | 374 | let resolver = def.resolver(db); |
376 | 375 | ||
377 | Ty::from_hir(db, &resolver, signature.type_ref()) | 376 | Ty::from_hir(db, &resolver, data.type_ref()) |
378 | } | 377 | } |
379 | 378 | ||
380 | /// Build the declared type of a static. | 379 | /// Build the declared type of a static. |
381 | fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { | 380 | fn type_for_static(db: &impl HirDatabase, def: Static) -> Ty { |
382 | let signature = def.signature(db); | 381 | let data = def.data(db); |
383 | let resolver = def.resolver(db); | 382 | let resolver = def.resolver(db); |
384 | 383 | ||
385 | Ty::from_hir(db, &resolver, signature.type_ref()) | 384 | Ty::from_hir(db, &resolver, data.type_ref()) |
386 | } | 385 | } |
387 | 386 | ||
388 | /// Build the declared type of a static. | 387 | /// Build the declared type of a static. |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index ad26d591c..46ec136bd 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -192,8 +192,8 @@ fn iterate_trait_method_candidates<T>( | |||
192 | let mut known_implemented = false; | 192 | let mut known_implemented = false; |
193 | for item in data.items() { | 193 | for item in data.items() { |
194 | if let TraitItem::Function(m) = *item { | 194 | if let TraitItem::Function(m) = *item { |
195 | let sig = m.signature(db); | 195 | let data = m.data(db); |
196 | if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() { | 196 | if name.map_or(true, |name| data.name() == name) && data.has_self_param() { |
197 | if !known_implemented { | 197 | if !known_implemented { |
198 | let trait_ref = canonical_trait_ref(db, t, ty.clone()); | 198 | let trait_ref = canonical_trait_ref(db, t, ty.clone()); |
199 | if db.implements(krate, trait_ref).is_none() { | 199 | if db.implements(krate, trait_ref).is_none() { |
@@ -227,8 +227,8 @@ fn iterate_inherent_methods<T>( | |||
227 | for impl_block in impls.lookup_impl_blocks(&ty.value) { | 227 | for impl_block in impls.lookup_impl_blocks(&ty.value) { |
228 | for item in impl_block.items(db) { | 228 | for item in impl_block.items(db) { |
229 | if let ImplItem::Method(f) = item { | 229 | if let ImplItem::Method(f) = item { |
230 | let sig = f.signature(db); | 230 | let data = f.data(db); |
231 | if name.map_or(true, |name| sig.name() == name) && sig.has_self_param() { | 231 | if name.map_or(true, |name| data.name() == name) && data.has_self_param() { |
232 | if let Some(result) = callback(&ty.value, f) { | 232 | if let Some(result) = callback(&ty.value, f) { |
233 | return Some(result); | 233 | return Some(result); |
234 | } | 234 | } |