diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-20 18:16:35 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-20 18:16:35 +0000 |
commit | 5aec3e4a7b21855fb4688e466d4f5bee9feabe2e (patch) | |
tree | 41a304a33955dd12d1f0ec127a80551367c8ffa0 /crates/ra_ide_api/src | |
parent | 7a5fd1f3f3c4a8f64407f9bd08a3d5e7f79417e0 (diff) | |
parent | bcb2ea912bf96f38505c67a0b6896c6a5ac278ed (diff) |
Merge #2329
2329: fix 2190; add test for "replace if let with match" r=matklad a=fkohlgrueber
Fixes #2190.
Check that the expression doesn't contain newlines only for "replace if let with match". For "join lines", enclosing blocks for multiline expressions should be removed.
Co-authored-by: Felix Kohlgrüber <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/join_lines.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs index 6f71b27db..7deeb3494 100644 --- a/crates/ra_ide_api/src/join_lines.rs +++ b/crates/ra_ide_api/src/join_lines.rs | |||
@@ -244,6 +244,34 @@ fn foo(e: Result<U, V>) { | |||
244 | } | 244 | } |
245 | 245 | ||
246 | #[test] | 246 | #[test] |
247 | fn join_lines_multiline_in_block() { | ||
248 | check_join_lines( | ||
249 | r" | ||
250 | fn foo() { | ||
251 | match ty { | ||
252 | <|> Some(ty) => { | ||
253 | match ty { | ||
254 | _ => false, | ||
255 | } | ||
256 | } | ||
257 | _ => true, | ||
258 | } | ||
259 | } | ||
260 | ", | ||
261 | r" | ||
262 | fn foo() { | ||
263 | match ty { | ||
264 | <|> Some(ty) => match ty { | ||
265 | _ => false, | ||
266 | }, | ||
267 | _ => true, | ||
268 | } | ||
269 | } | ||
270 | ", | ||
271 | ); | ||
272 | } | ||
273 | |||
274 | #[test] | ||
247 | fn join_lines_keeps_comma_for_block_in_match_arm() { | 275 | fn join_lines_keeps_comma_for_block_in_match_arm() { |
248 | // We already have a comma | 276 | // We already have a comma |
249 | check_join_lines( | 277 | check_join_lines( |