From 8965be3d0e5162c8a39c5ba1fd074740ac732566 Mon Sep 17 00:00:00 2001 From: Dawer <7803845+iDawer@users.noreply.github.com> Date: Fri, 16 Apr 2021 17:22:11 +0500 Subject: Fill match arms for a tuple of a single enum. --- crates/ide_assists/src/handlers/fill_match_arms.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'crates/ide_assists/src/handlers/fill_match_arms.rs') diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs index 878b3a3fa..80bd1b7e8 100644 --- a/crates/ide_assists/src/handlers/fill_match_arms.rs +++ b/crates/ide_assists/src/handlers/fill_match_arms.rs @@ -71,12 +71,6 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< return None; } - // We do not currently support filling match arms for a tuple - // containing a single enum. - if enum_defs.len() < 2 { - return None; - } - // When calculating the match arms for a tuple of enums, we want // to create a match arm for each possible combination of enum // values. The `multi_cartesian_product` method transforms @@ -514,10 +508,7 @@ fn main() { #[test] fn fill_match_arms_single_element_tuple_of_enum() { - // For now we don't hande the case of a single element tuple, but - // we could handle this in the future if `make::tuple_pat` allowed - // creating a tuple with a single pattern. - check_assist_not_applicable( + check_assist( fill_match_arms, r#" enum A { One, Two } @@ -528,6 +519,17 @@ fn main() { } } "#, + r#" + enum A { One, Two } + + fn main() { + let a = A::One; + match (a, ) { + $0(A::One,) => {} + (A::Two,) => {} + } + } + "#, ); } -- cgit v1.2.3