aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index b736098ac..5438b8650 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -23,7 +23,7 @@ impl ast::BinExpr {
23 pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> { 23 pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> {
24 let op_node: SyntaxElement = self.op_details()?.0.into(); 24 let op_node: SyntaxElement = self.op_details()?.0.into();
25 let to_insert: Option<SyntaxElement> = Some(tokens::op(op).into()); 25 let to_insert: Option<SyntaxElement> = Some(tokens::op(op).into());
26 let replace_range = RangeInclusive::new(op_node.clone(), op_node); 26 let replace_range = op_node.clone()..=op_node;
27 Some(replace_children(self, replace_range, to_insert.into_iter())) 27 Some(replace_children(self, replace_range, to_insert.into_iter()))
28 } 28 }
29} 29}
@@ -43,7 +43,7 @@ impl ast::FnDef {
43 return insert_children(self, InsertPosition::Last, to_insert.into_iter()); 43 return insert_children(self, InsertPosition::Last, to_insert.into_iter());
44 }; 44 };
45 to_insert.push(body.syntax().clone().into()); 45 to_insert.push(body.syntax().clone().into());
46 let replace_range = RangeInclusive::new(old_body_or_semi.clone(), old_body_or_semi); 46 let replace_range = old_body_or_semi.clone()..=old_body_or_semi;
47 replace_children(self, replace_range, to_insert.into_iter()) 47 replace_children(self, replace_range, to_insert.into_iter())
48 } 48 }
49} 49}
@@ -109,9 +109,7 @@ impl ast::ItemList {
109 let to_insert = iter::once(ws.ws().into()); 109 let to_insert = iter::once(ws.ws().into());
110 match existing_ws { 110 match existing_ws {
111 None => insert_children(self, InsertPosition::After(l_curly), to_insert), 111 None => insert_children(self, InsertPosition::After(l_curly), to_insert),
112 Some(ws) => { 112 Some(ws) => replace_children(self, ws.clone().into()..=ws.into(), to_insert),
113 replace_children(self, RangeInclusive::new(ws.clone().into(), ws.into()), to_insert)
114 }
115 } 113 }
116 } 114 }
117} 115}
@@ -207,7 +205,7 @@ impl ast::TypeParam {
207 Some(it) => it.syntax().clone().into(), 205 Some(it) => it.syntax().clone().into(),
208 None => colon.clone().into(), 206 None => colon.clone().into(),
209 }; 207 };
210 replace_children(self, RangeInclusive::new(colon.into(), end), iter::empty()) 208 replace_children(self, colon.into()..=end, iter::empty())
211 } 209 }
212} 210}
213 211
@@ -224,7 +222,7 @@ fn strip_attrs_and_docs_inner(mut node: SyntaxNode) -> SyntaxNode {
224 Some(el) if el.kind() == WHITESPACE => el.clone(), 222 Some(el) if el.kind() == WHITESPACE => el.clone(),
225 Some(_) | None => start.clone(), 223 Some(_) | None => start.clone(),
226 }; 224 };
227 node = algo::replace_children(&node, RangeInclusive::new(start, end), &mut iter::empty()); 225 node = algo::replace_children(&node, start..=end, &mut iter::empty());
228 } 226 }
229 node 227 node
230} 228}