mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
clippy: Use if lets and remove redundant returns
This commit is contained in:
parent
5db663d61f
commit
d493a4476c
11 changed files with 22 additions and 29 deletions
|
@ -38,12 +38,12 @@ pub fn folding_ranges(file: &File) -> Vec<Fold> {
|
|||
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,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -54,15 +54,15 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> {
|
|||
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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue