aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs32
-rw-r--r--crates/ra_hir/src/ty/infer.rs2
2 files changed, 17 insertions, 17 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 7d5d9b995..b2fb5a563 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -240,10 +240,10 @@ impl Module {
240 } 240 }
241 241
242 pub fn path_to_root(self, db: &impl HirDatabase) -> Vec<Module> { 242 pub fn path_to_root(self, db: &impl HirDatabase) -> Vec<Module> {
243 let mut res = vec![self.clone()]; 243 let mut res = vec![self];
244 let mut curr = self.clone(); 244 let mut curr = self;
245 while let Some(next) = curr.parent(db) { 245 while let Some(next) = curr.parent(db) {
246 res.push(next.clone()); 246 res.push(next);
247 curr = next 247 curr = next
248 } 248 }
249 res 249 res
@@ -299,7 +299,7 @@ impl Module {
299 .collect() 299 .collect()
300 } 300 }
301 301
302 fn with_module_id(&self, module_id: CrateModuleId) -> Module { 302 fn with_module_id(self, module_id: CrateModuleId) -> Module {
303 Module { module_id, krate: self.krate } 303 Module { module_id, krate: self.krate }
304 } 304 }
305} 305}
@@ -463,33 +463,33 @@ pub struct EnumVariant {
463} 463}
464 464
465impl EnumVariant { 465impl EnumVariant {
466 pub fn module(&self, db: &impl HirDatabase) -> Module { 466 pub fn module(self, db: &impl HirDatabase) -> Module {
467 self.parent.module(db) 467 self.parent.module(db)
468 } 468 }
469 pub fn parent_enum(&self, _db: &impl DefDatabase) -> Enum { 469 pub fn parent_enum(self, _db: &impl DefDatabase) -> Enum {
470 self.parent 470 self.parent
471 } 471 }
472 472
473 pub fn name(&self, db: &impl DefDatabase) -> Option<Name> { 473 pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
474 db.enum_data(self.parent).variants[self.id].name.clone() 474 db.enum_data(self.parent).variants[self.id].name.clone()
475 } 475 }
476 476
477 pub fn fields(&self, db: &impl HirDatabase) -> Vec<StructField> { 477 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
478 self.variant_data(db) 478 self.variant_data(db)
479 .fields() 479 .fields()
480 .into_iter() 480 .into_iter()
481 .flat_map(|it| it.iter()) 481 .flat_map(|it| it.iter())
482 .map(|(id, _)| StructField { parent: (*self).into(), id }) 482 .map(|(id, _)| StructField { parent: self.into(), id })
483 .collect() 483 .collect()
484 } 484 }
485 485
486 pub fn field(&self, db: &impl HirDatabase, name: &Name) -> Option<StructField> { 486 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
487 self.variant_data(db) 487 self.variant_data(db)
488 .fields() 488 .fields()
489 .into_iter() 489 .into_iter()
490 .flat_map(|it| it.iter()) 490 .flat_map(|it| it.iter())
491 .find(|(_id, data)| data.name == *name) 491 .find(|(_id, data)| data.name == *name)
492 .map(|(id, _)| StructField { parent: (*self).into(), id }) 492 .map(|(id, _)| StructField { parent: self.into(), id })
493 } 493 }
494} 494}
495 495
@@ -517,11 +517,11 @@ impl DefWithBody {
517 } 517 }
518 518
519 /// Builds a resolver for code inside this item. 519 /// Builds a resolver for code inside this item.
520 pub(crate) fn resolver(&self, db: &impl HirDatabase) -> Resolver { 520 pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
521 match *self { 521 match self {
522 DefWithBody::Const(ref c) => c.resolver(db), 522 DefWithBody::Const(c) => c.resolver(db),
523 DefWithBody::Function(ref f) => f.resolver(db), 523 DefWithBody::Function(f) => f.resolver(db),
524 DefWithBody::Static(ref s) => s.resolver(db), 524 DefWithBody::Static(s) => s.resolver(db),
525 } 525 }
526 } 526 }
527} 527}
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index f47f4c5de..8322de0a8 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -529,7 +529,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
529 match matching_def { 529 match matching_def {
530 Some(_) => { 530 Some(_) => {
531 self.write_assoc_resolution(id, item); 531 self.write_assoc_resolution(id, item);
532 return matching_def; 532 matching_def
533 } 533 }
534 None => None, 534 None => None,
535 } 535 }