aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers
diff options
context:
space:
mode:
authorDawer <[email protected]>2021-05-21 07:27:41 +0100
committerDawer <[email protected]>2021-05-21 07:29:24 +0100
commitd5c96672aac6fd4ac25474814879af2c04bd798b (patch)
treeb09c3978d4d040c51b50dd44ac9f7e2546254bba /crates/ide_assists/src/handlers
parent570eff655208b5f7d28d2e0a587ee514b91b4a42 (diff)
Test `fill_match_arms` for lazy computation.
This also adds `ide_assists::tests::check_assist_unresolved` function.
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}