aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-05 15:19:12 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-05 15:19:12 +0100
commitec6f71576ace170fd306a68f77e5c5e9646d15be (patch)
treed39853a3366ea849b60b342240a5908f16899dcf /crates/ra_hir/src/code_model.rs
parent3be2d1db6c04a99efdd32b1af724caeb10d9676b (diff)
parent98d769a799e430f152e573c28f101d9d6aee5376 (diff)
Merge #1491
1491: More clippy r=matklad a=kjeremy A few more clippy changes. I'm a little unsure of the second commit. It's the trivially_copy_pass_by_ref lint and there are a number of places in the code we could use it if it makes sense. Co-authored-by: Jeremy Kolb <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs32
1 files changed, 16 insertions, 16 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}