aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src/handlers')
-rw-r--r--crates/ide_assists/src/handlers/fill_match_arms.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs
index 3532759bf..97435f021 100644
--- a/crates/ide_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ide_assists/src/handlers/fill_match_arms.rs
@@ -105,6 +105,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
105 let missing_pats = variants_of_enums 105 let missing_pats = variants_of_enums
106 .into_iter() 106 .into_iter()
107 .multi_cartesian_product() 107 .multi_cartesian_product()
108 .inspect(|_| cov_mark::hit!(fill_match_arms_lazy_computation))
108 .map(|variants| { 109 .map(|variants| {
109 let patterns = 110 let patterns =
110 variants.into_iter().filter_map(|variant| build_pat(ctx.db(), module, variant)); 111 variants.into_iter().filter_map(|variant| build_pat(ctx.db(), module, variant));
@@ -279,7 +280,9 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: ExtendedVariant) -> Op
279mod tests { 280mod tests {
280 use ide_db::helpers::FamousDefs; 281 use ide_db::helpers::FamousDefs;
281 282
282 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 283 use crate::tests::{
284 check_assist, check_assist_not_applicable, check_assist_target, check_assist_unresolved,
285 };
283 286
284 use super::fill_match_arms; 287 use super::fill_match_arms;
285 288
@@ -1058,4 +1061,19 @@ fn foo(t: Test) {
1058}"#, 1061}"#,
1059 ); 1062 );
1060 } 1063 }
1064
1065 #[test]
1066 fn lazy_computation() {
1067 // Computing a single missing arm is enough to determine applicability of the assist.
1068 cov_mark::check_count!(fill_match_arms_lazy_computation, 1);
1069 check_assist_unresolved(
1070 fill_match_arms,
1071 r#"
1072enum A { One, Two, }
1073fn foo(tuple: (A, A)) {
1074 match $0tuple {};
1075}
1076"#,
1077 );
1078 }
1061} 1079}