diff options
Diffstat (limited to 'crates/assists/src/handlers/move_guard.rs')
-rw-r--r-- | crates/assists/src/handlers/move_guard.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/assists/src/handlers/move_guard.rs b/crates/assists/src/handlers/move_guard.rs index eaffd80ce..3f22302a9 100644 --- a/crates/assists/src/handlers/move_guard.rs +++ b/crates/assists/src/handlers/move_guard.rs | |||
@@ -14,7 +14,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
14 | // | 14 | // |
15 | // fn handle(action: Action) { | 15 | // fn handle(action: Action) { |
16 | // match action { | 16 | // match action { |
17 | // Action::Move { distance } <|>if distance > 10 => foo(), | 17 | // Action::Move { distance } $0if distance > 10 => foo(), |
18 | // _ => (), | 18 | // _ => (), |
19 | // } | 19 | // } |
20 | // } | 20 | // } |
@@ -74,7 +74,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> | |||
74 | // | 74 | // |
75 | // fn handle(action: Action) { | 75 | // fn handle(action: Action) { |
76 | // match action { | 76 | // match action { |
77 | // Action::Move { distance } => <|>if distance > 10 { foo() }, | 77 | // Action::Move { distance } => $0if distance > 10 { foo() }, |
78 | // _ => (), | 78 | // _ => (), |
79 | // } | 79 | // } |
80 | // } | 80 | // } |
@@ -98,7 +98,7 @@ pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContex | |||
98 | let mut replace_node = None; | 98 | let mut replace_node = None; |
99 | let if_expr: IfExpr = IfExpr::cast(arm_body.syntax().clone()).or_else(|| { | 99 | let if_expr: IfExpr = IfExpr::cast(arm_body.syntax().clone()).or_else(|| { |
100 | let block_expr = BlockExpr::cast(arm_body.syntax().clone())?; | 100 | let block_expr = BlockExpr::cast(arm_body.syntax().clone())?; |
101 | if let Expr::IfExpr(e) = block_expr.expr()? { | 101 | if let Expr::IfExpr(e) = block_expr.tail_expr()? { |
102 | replace_node = Some(block_expr.syntax().clone()); | 102 | replace_node = Some(block_expr.syntax().clone()); |
103 | Some(e) | 103 | Some(e) |
104 | } else { | 104 | } else { |
@@ -128,7 +128,7 @@ pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContex | |||
128 | |edit| { | 128 | |edit| { |
129 | let then_only_expr = then_block.statements().next().is_none(); | 129 | let then_only_expr = then_block.statements().next().is_none(); |
130 | 130 | ||
131 | match &then_block.expr() { | 131 | match &then_block.tail_expr() { |
132 | Some(then_expr) if then_only_expr => { | 132 | Some(then_expr) if then_only_expr => { |
133 | edit.replace(replace_node.text_range(), then_expr.syntax().text()) | 133 | edit.replace(replace_node.text_range(), then_expr.syntax().text()) |
134 | } | 134 | } |
@@ -158,7 +158,7 @@ mod tests { | |||
158 | r#" | 158 | r#" |
159 | fn main() { | 159 | fn main() { |
160 | match 92 { | 160 | match 92 { |
161 | x <|>if x > 10 => false, | 161 | x $0if x > 10 => false, |
162 | _ => true | 162 | _ => true |
163 | } | 163 | } |
164 | } | 164 | } |
@@ -174,7 +174,7 @@ fn main() { | |||
174 | r#" | 174 | r#" |
175 | fn main() { | 175 | fn main() { |
176 | match 92 { | 176 | match 92 { |
177 | x <|>if x > 10 => false, | 177 | x $0if x > 10 => false, |
178 | _ => true | 178 | _ => true |
179 | } | 179 | } |
180 | } | 180 | } |
@@ -199,7 +199,7 @@ fn main() { | |||
199 | r#" | 199 | r#" |
200 | fn main() { | 200 | fn main() { |
201 | match 92 { | 201 | match 92 { |
202 | <|>x @ 4 | x @ 5 if x > 5 => true, | 202 | $0x @ 4 | x @ 5 if x > 5 => true, |
203 | _ => false | 203 | _ => false |
204 | } | 204 | } |
205 | } | 205 | } |
@@ -224,7 +224,7 @@ fn main() { | |||
224 | r#" | 224 | r#" |
225 | fn main() { | 225 | fn main() { |
226 | match 92 { | 226 | match 92 { |
227 | x => if x > 10 { <|>false }, | 227 | x => if x > 10 { $0false }, |
228 | _ => true | 228 | _ => true |
229 | } | 229 | } |
230 | } | 230 | } |
@@ -248,7 +248,7 @@ fn main() { | |||
248 | fn main() { | 248 | fn main() { |
249 | match 92 { | 249 | match 92 { |
250 | x => { | 250 | x => { |
251 | <|>if x > 10 { | 251 | $0if x > 10 { |
252 | false | 252 | false |
253 | } | 253 | } |
254 | }, | 254 | }, |
@@ -274,7 +274,7 @@ fn main() { | |||
274 | r#" | 274 | r#" |
275 | fn main() { | 275 | fn main() { |
276 | match 92 { | 276 | match 92 { |
277 | x => if let 62 = x { <|>false }, | 277 | x => if let 62 = x { $0false }, |
278 | _ => true | 278 | _ => true |
279 | } | 279 | } |
280 | } | 280 | } |
@@ -289,7 +289,7 @@ fn main() { | |||
289 | r#" | 289 | r#" |
290 | fn main() { | 290 | fn main() { |
291 | match 92 { | 291 | match 92 { |
292 | x => if x > 10 { <|> }, | 292 | x => if x > 10 { $0 }, |
293 | _ => true | 293 | _ => true |
294 | } | 294 | } |
295 | } | 295 | } |
@@ -313,7 +313,7 @@ fn main() { | |||
313 | fn main() { | 313 | fn main() { |
314 | match 92 { | 314 | match 92 { |
315 | x => if x > 10 { | 315 | x => if x > 10 { |
316 | 92;<|> | 316 | 92;$0 |
317 | false | 317 | false |
318 | }, | 318 | }, |
319 | _ => true | 319 | _ => true |
@@ -343,7 +343,7 @@ fn main() { | |||
343 | match 92 { | 343 | match 92 { |
344 | x => { | 344 | x => { |
345 | if x > 10 { | 345 | if x > 10 { |
346 | 92;<|> | 346 | 92;$0 |
347 | false | 347 | false |
348 | } | 348 | } |
349 | } | 349 | } |