From c955ea11b42dc7c0ac91fe1a12427171b86be4b7 Mon Sep 17 00:00:00 2001 From: Jeroen Vannevel Date: Fri, 14 Jan 2022 00:35:21 +0000 Subject: [PATCH] support TuplePat --- .../src/handlers/merge_match_arms.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/ide_assists/src/handlers/merge_match_arms.rs b/crates/ide_assists/src/handlers/merge_match_arms.rs index 0ef4678d11..ff1804fe95 100644 --- a/crates/ide_assists/src/handlers/merge_match_arms.rs +++ b/crates/ide_assists/src/handlers/merge_match_arms.rs @@ -131,6 +131,11 @@ fn get_arm_types(context: &AssistContext, arm: &MatchArm) -> HashMap { + for field in tuple.fields() { + recurse(&Some(field), map, ctx); + } + } Some(ast::Pat::RecordPat(record)) => { if let Some(field_list) = record.record_pat_field_list() { for field in field_list.fields() { @@ -707,6 +712,21 @@ fn main(msg: Message) { Message::ChangeColor(y, Color::Hsv(x, b, c)) => "", _ => "other" }; +} + "#, + ) + } + + #[test] + fn merge_match_arms_tuple() { + check_assist_not_applicable( + merge_match_arms, + r#" +fn func() { + match (0, "boo") { + (x, y) => $0"", + (y, x) => "", + }; } "#, )