From d493a4476c2059924d032fbf01dda091601f9667 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 11:51:58 -0400 Subject: clippy: Use if lets and remove redundant returns --- crates/ra_syntax/src/algo/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax/src/algo') diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs index 9d2014bc7..87f1250bc 100644 --- a/crates/ra_syntax/src/algo/mod.rs +++ b/crates/ra_syntax/src/algo/mod.rs @@ -30,7 +30,8 @@ pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffse let left = children.next().unwrap(); let right = children.next(); assert!(children.next().is_none()); - return if let Some(right) = right { + + if let Some(right) = right { match ( find_leaf_at_offset(left, offset), find_leaf_at_offset(right, offset), @@ -42,7 +43,7 @@ pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffse } } else { find_leaf_at_offset(left, offset) - }; + } } #[derive(Clone, Copy, Debug)] -- cgit v1.2.3 From 4e8ea94e2b72a3e927c8ff1b5f3fe2413ccc79a7 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 11:54:29 -0400 Subject: Remove Copy trait on LeafAtOffset Because it's a stateful iterator, it's easier to explicitly clone it when necesary. Fixes clippy:clone_on_copy --- crates/ra_syntax/src/algo/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/algo') diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs index 87f1250bc..d82c42b3e 100644 --- a/crates/ra_syntax/src/algo/mod.rs +++ b/crates/ra_syntax/src/algo/mod.rs @@ -46,7 +46,7 @@ pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffse } } -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Debug)] pub enum LeafAtOffset<'a> { None, Single(SyntaxNodeRef<'a>), -- cgit v1.2.3