aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/code_model.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index b3a4f4d63..b27537151 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -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}