mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Simplify
This commit is contained in:
parent
263401bf75
commit
448575aa4a
1 changed files with 5 additions and 7 deletions
|
@ -23,7 +23,7 @@ impl ast::BinExpr {
|
|||
pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> {
|
||||
let op_node: SyntaxElement = self.op_details()?.0.into();
|
||||
let to_insert: Option<SyntaxElement> = Some(tokens::op(op).into());
|
||||
let replace_range = RangeInclusive::new(op_node.clone(), op_node);
|
||||
let replace_range = op_node.clone()..=op_node;
|
||||
Some(replace_children(self, replace_range, to_insert.into_iter()))
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ impl ast::FnDef {
|
|||
return insert_children(self, InsertPosition::Last, to_insert.into_iter());
|
||||
};
|
||||
to_insert.push(body.syntax().clone().into());
|
||||
let replace_range = RangeInclusive::new(old_body_or_semi.clone(), old_body_or_semi);
|
||||
let replace_range = old_body_or_semi.clone()..=old_body_or_semi;
|
||||
replace_children(self, replace_range, to_insert.into_iter())
|
||||
}
|
||||
}
|
||||
|
@ -109,9 +109,7 @@ impl ast::ItemList {
|
|||
let to_insert = iter::once(ws.ws().into());
|
||||
match existing_ws {
|
||||
None => insert_children(self, InsertPosition::After(l_curly), to_insert),
|
||||
Some(ws) => {
|
||||
replace_children(self, RangeInclusive::new(ws.clone().into(), ws.into()), to_insert)
|
||||
}
|
||||
Some(ws) => replace_children(self, ws.clone().into()..=ws.into(), to_insert),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +205,7 @@ impl ast::TypeParam {
|
|||
Some(it) => it.syntax().clone().into(),
|
||||
None => colon.clone().into(),
|
||||
};
|
||||
replace_children(self, RangeInclusive::new(colon.into(), end), iter::empty())
|
||||
replace_children(self, colon.into()..=end, iter::empty())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +222,7 @@ fn strip_attrs_and_docs_inner(mut node: SyntaxNode) -> SyntaxNode {
|
|||
Some(el) if el.kind() == WHITESPACE => el.clone(),
|
||||
Some(_) | None => start.clone(),
|
||||
};
|
||||
node = algo::replace_children(&node, RangeInclusive::new(start, end), &mut iter::empty());
|
||||
node = algo::replace_children(&node, start..=end, &mut iter::empty());
|
||||
}
|
||||
node
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue