diff options
author | Alan Du <[email protected]> | 2019-06-03 15:27:51 +0100 |
---|---|---|
committer | Alan Du <[email protected]> | 2019-06-04 23:05:07 +0100 |
commit | b28ca32db22d5e2ed34db556c6fd50a5fc2d679c (patch) | |
tree | 7e86e3f6ffdbc972b2ac968503f2b3671fd9b3a5 /crates/ra_hir/src | |
parent | 40424d4222d4630bc53294d10f1718f2d3d300de (diff) |
Fix clippy::or_fun_call
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/lang_item.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 17 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 2 |
4 files changed, 14 insertions, 9 deletions
diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs index 4cacaeba4..684fbc068 100644 --- a/crates/ra_hir/src/lang_item.rs +++ b/crates/ra_hir/src/lang_item.rs | |||
@@ -95,7 +95,7 @@ impl LangItems { | |||
95 | .nth(0); | 95 | .nth(0); |
96 | if let Some(lang_item_name) = lang_item_name { | 96 | if let Some(lang_item_name) = lang_item_name { |
97 | let imp = ImplBlock::from_id(*module, impl_id); | 97 | let imp = ImplBlock::from_id(*module, impl_id); |
98 | self.items.entry(lang_item_name).or_insert(LangItemTarget::ImplBlock(imp)); | 98 | self.items.entry(lang_item_name).or_insert_with(|| LangItemTarget::ImplBlock(imp)); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index d822f7d93..7bddee9b9 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -332,7 +332,8 @@ impl CrateDefMap { | |||
332 | let name = path.expand_macro_expr()?; | 332 | let name = path.expand_macro_expr()?; |
333 | // search local first | 333 | // search local first |
334 | // FIXME: Remove public_macros check when we have a correct local_macors implementation | 334 | // FIXME: Remove public_macros check when we have a correct local_macors implementation |
335 | let local = self.public_macros.get(&name).or(self.local_macros.get(&name)).map(|it| *it); | 335 | let local = |
336 | self.public_macros.get(&name).or_else(|| self.local_macros.get(&name)).map(|it| *it); | ||
336 | if local.is_some() { | 337 | if local.is_some() { |
337 | return local; | 338 | return local; |
338 | } | 339 | } |
@@ -479,8 +480,10 @@ impl CrateDefMap { | |||
479 | } | 480 | } |
480 | 481 | ||
481 | fn resolve_name_in_crate_root_or_extern_prelude(&self, name: &Name) -> ItemOrMacro { | 482 | fn resolve_name_in_crate_root_or_extern_prelude(&self, name: &Name) -> ItemOrMacro { |
482 | let from_crate_root = | 483 | let from_crate_root = self[self.root] |
483 | self[self.root].scope.get_item_or_macro(name).unwrap_or(Either::Left(PerNs::none())); | 484 | .scope |
485 | .get_item_or_macro(name) | ||
486 | .unwrap_or_else(|| Either::Left(PerNs::none())); | ||
484 | let from_extern_prelude = self.resolve_name_in_extern_prelude(name); | 487 | let from_extern_prelude = self.resolve_name_in_extern_prelude(name); |
485 | 488 | ||
486 | or(from_crate_root, Either::Left(from_extern_prelude)) | 489 | or(from_crate_root, Either::Left(from_extern_prelude)) |
@@ -505,8 +508,10 @@ impl CrateDefMap { | |||
505 | // - current module / scope | 508 | // - current module / scope |
506 | // - extern prelude | 509 | // - extern prelude |
507 | // - std prelude | 510 | // - std prelude |
508 | let from_scope = | 511 | let from_scope = self[module] |
509 | self[module].scope.get_item_or_macro(name).unwrap_or(Either::Left(PerNs::none()));; | 512 | .scope |
513 | .get_item_or_macro(name) | ||
514 | .unwrap_or_else(|| Either::Left(PerNs::none()));; | ||
510 | let from_extern_prelude = | 515 | let from_extern_prelude = |
511 | self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it)); | 516 | self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it)); |
512 | let from_prelude = self.resolve_in_prelude(db, name); | 517 | let from_prelude = self.resolve_in_prelude(db, name); |
@@ -525,7 +530,7 @@ impl CrateDefMap { | |||
525 | } else { | 530 | } else { |
526 | db.crate_def_map(prelude.krate)[prelude.module_id].scope.get_item_or_macro(name) | 531 | db.crate_def_map(prelude.krate)[prelude.module_id].scope.get_item_or_macro(name) |
527 | }; | 532 | }; |
528 | resolution.unwrap_or(Either::Left(PerNs::none())) | 533 | resolution.unwrap_or_else(|| Either::Left(PerNs::none())) |
529 | } else { | 534 | } else { |
530 | Either::Left(PerNs::none()) | 535 | Either::Left(PerNs::none()) |
531 | } | 536 | } |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 76d34c12b..4a37e0268 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -451,7 +451,7 @@ impl Ty { | |||
451 | /// Substitutes `Ty::Bound` vars (as opposed to type parameters). | 451 | /// Substitutes `Ty::Bound` vars (as opposed to type parameters). |
452 | pub fn subst_bound_vars(self, substs: &Substs) -> Ty { | 452 | pub fn subst_bound_vars(self, substs: &Substs) -> Ty { |
453 | self.fold(&mut |ty| match ty { | 453 | self.fold(&mut |ty| match ty { |
454 | Ty::Bound(idx) => substs.get(idx as usize).cloned().unwrap_or(Ty::Bound(idx)), | 454 | Ty::Bound(idx) => substs.get(idx as usize).cloned().unwrap_or_else(|| Ty::Bound(idx)), |
455 | ty => ty, | 455 | ty => ty, |
456 | }) | 456 | }) |
457 | } | 457 | } |
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 5edc59f18..905fe9f0e 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -462,7 +462,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
462 | let mut resolved = | 462 | let mut resolved = |
463 | if remaining_index.is_none() { def.take_values()? } else { def.take_types()? }; | 463 | if remaining_index.is_none() { def.take_values()? } else { def.take_types()? }; |
464 | 464 | ||
465 | let remaining_index = remaining_index.unwrap_or(path.segments.len()); | 465 | let remaining_index = remaining_index.unwrap_or_else(|| path.segments.len()); |
466 | let mut actual_def_ty: Option<Ty> = None; | 466 | let mut actual_def_ty: Option<Ty> = None; |
467 | 467 | ||
468 | let krate = resolver.krate()?; | 468 | let krate = resolver.krate()?; |