From 5e4370fe56153df73c51cb532f0f1bf4c261b094 Mon Sep 17 00:00:00 2001 From: Jeroen Vannevel Date: Fri, 14 Jan 2022 01:20:40 +0000 Subject: [PATCH] happy slice --- .../src/handlers/merge_match_arms.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/ide_assists/src/handlers/merge_match_arms.rs b/crates/ide_assists/src/handlers/merge_match_arms.rs index 209d352c78..5337b968c5 100644 --- a/crates/ide_assists/src/handlers/merge_match_arms.rs +++ b/crates/ide_assists/src/handlers/merge_match_arms.rs @@ -791,4 +791,39 @@ fn func(binary: &[u8]) { "#, ) } + + #[test] + fn merge_match_arms_slice_identical() { + check_assist( + merge_match_arms, + r#" +fn func(binary: &[u8]) { + let space = b' '; + match binary { + [space, 5u8] => $0"", + [space] => "", + _ => "other", + }; } + "#, + r#" +fn func(binary: &[u8]) { + let space = b' '; + match binary { + [space, 5u8] | [space] => "", + _ => "other", + }; +} + "#, + ) + } +} + +fn func(binary: &[u8]) { + let space = b' '; + match binary { + [space, 5u8] => "", + [space] => "", + _ => "other", + }; +} \ No newline at end of file