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_editor/src/folding_ranges.rs | 4 ++-- crates/ra_editor/src/line_index.rs | 4 ++-- crates/ra_editor/src/symbols.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_editor/src') diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs index e5bc0c4ee..d0d4ed3d3 100644 --- a/crates/ra_editor/src/folding_ranges.rs +++ b/crates/ra_editor/src/folding_ranges.rs @@ -38,12 +38,12 @@ pub fn folding_ranges(file: &File) -> Vec { continue; } if node.kind() == COMMENT { - contiguous_range_for_comment(node, &mut visited_comments).map(|range| { + if let Some(range) = contiguous_range_for_comment(node, &mut visited_comments) { res.push(Fold { range, kind: FoldKind::Comment, }) - }); + } } } diff --git a/crates/ra_editor/src/line_index.rs b/crates/ra_editor/src/line_index.rs index da0f2a7f7..9abbb0d09 100644 --- a/crates/ra_editor/src/line_index.rs +++ b/crates/ra_editor/src/line_index.rs @@ -29,10 +29,10 @@ impl LineIndex { let line = self.newlines.upper_bound(&offset) - 1; let line_start_offset = self.newlines[line]; let col = offset - line_start_offset; - return LineCol { + LineCol { line: line as u32, col, - }; + } } pub fn offset(&self, line_col: LineCol) -> TextUnit { diff --git a/crates/ra_editor/src/symbols.rs b/crates/ra_editor/src/symbols.rs index c3c66680d..0bab9dd67 100644 --- a/crates/ra_editor/src/symbols.rs +++ b/crates/ra_editor/src/symbols.rs @@ -54,15 +54,15 @@ pub fn file_structure(file: &File) -> Vec { let mut res = Vec::new(); let mut stack = Vec::new(); + for event in file.syntax().preorder() { match event { - WalkEvent::Enter(node) => match structure_node(node) { - Some(mut symbol) => { + WalkEvent::Enter(node) => { + if let Some(mut symbol) = structure_node(node) { symbol.parent = stack.last().map(|&n| n); stack.push(res.len()); res.push(symbol); } - None => (), }, WalkEvent::Leave(node) => { if structure_node(node).is_some() { -- cgit v1.2.3