aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src
diff options
context:
space:
mode:
authorAlan Du <[email protected]>2018-10-16 16:51:58 +0100
committerAlan Du <[email protected]>2018-10-18 00:42:23 +0100
commitd493a4476c2059924d032fbf01dda091601f9667 (patch)
tree74c1249cba67c8c9824e618fcdea53b97b571a7b /crates/ra_editor/src
parent5db663d61fb8b006e3b84ef3bcc9cddbe94e5f49 (diff)
clippy: Use if lets and remove redundant returns
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r--crates/ra_editor/src/folding_ranges.rs4
-rw-r--r--crates/ra_editor/src/line_index.rs4
-rw-r--r--crates/ra_editor/src/symbols.rs6
3 files changed, 7 insertions, 7 deletions
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<Fold> {
38 continue; 38 continue;
39 } 39 }
40 if node.kind() == COMMENT { 40 if node.kind() == COMMENT {
41 contiguous_range_for_comment(node, &mut visited_comments).map(|range| { 41 if let Some(range) = contiguous_range_for_comment(node, &mut visited_comments) {
42 res.push(Fold { 42 res.push(Fold {
43 range, 43 range,
44 kind: FoldKind::Comment, 44 kind: FoldKind::Comment,
45 }) 45 })
46 }); 46 }
47 } 47 }
48 } 48 }
49 49
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 {
29 let line = self.newlines.upper_bound(&offset) - 1; 29 let line = self.newlines.upper_bound(&offset) - 1;
30 let line_start_offset = self.newlines[line]; 30 let line_start_offset = self.newlines[line];
31 let col = offset - line_start_offset; 31 let col = offset - line_start_offset;
32 return LineCol { 32 LineCol {
33 line: line as u32, 33 line: line as u32,
34 col, 34 col,
35 }; 35 }
36 } 36 }
37 37
38 pub fn offset(&self, line_col: LineCol) -> TextUnit { 38 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<StructureNode> {
54 let mut res = Vec::new(); 54 let mut res = Vec::new();
55 let mut stack = Vec::new(); 55 let mut stack = Vec::new();
56 56
57
57 for event in file.syntax().preorder() { 58 for event in file.syntax().preorder() {
58 match event { 59 match event {
59 WalkEvent::Enter(node) => match structure_node(node) { 60 WalkEvent::Enter(node) => {
60 Some(mut symbol) => { 61 if let Some(mut symbol) = structure_node(node) {
61 symbol.parent = stack.last().map(|&n| n); 62 symbol.parent = stack.last().map(|&n| n);
62 stack.push(res.len()); 63 stack.push(res.len());
63 res.push(symbol); 64 res.push(symbol);
64 } 65 }
65 None => (),
66 }, 66 },
67 WalkEvent::Leave(node) => { 67 WalkEvent::Leave(node) => {
68 if structure_node(node).is_some() { 68 if structure_node(node).is_some() {