aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManmeet Maan <[email protected]>2021-01-11 06:02:55 +0000
committerManmeet Maan <[email protected]>2021-01-11 06:02:55 +0000
commit430dc5cd248c709049f5ea6d48170ae79d2a329f (patch)
tree24aa06acb1414cde342a82ed1e5392ee619a325a
parent0d84adad353a09b8b29e862e80bf68da49c4481b (diff)
Apply Suggestions from code review
-rw-r--r--crates/completion/src/completions/postfix.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/crates/completion/src/completions/postfix.rs b/crates/completion/src/completions/postfix.rs
index ec91f87f2..b07e9325a 100644
--- a/crates/completion/src/completions/postfix.rs
+++ b/crates/completion/src/completions/postfix.rs
@@ -30,22 +30,19 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
30 let receiver_text = 30 let receiver_text =
31 get_receiver_text(dot_receiver, ctx.dot_receiver_is_ambiguous_float_literal); 31 get_receiver_text(dot_receiver, ctx.dot_receiver_is_ambiguous_float_literal);
32 32
33 let mut receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) { 33 let receiver_ty = match ctx.sema.type_of_expr(&dot_receiver) {
34 Some(it) => it, 34 Some(it) => it,
35 None => return, 35 None => return,
36 }; 36 };
37 37
38 let mut ref_removed = false; 38 let ref_removed_ty =
39 if let Some(removed) = receiver_ty.remove_ref() { 39 std::iter::successors(Some(receiver_ty.clone()), |ty| ty.remove_ref()).last().unwrap();
40 receiver_ty = removed; 40
41 ref_removed = true;
42 }
43
44 let cap = match ctx.config.snippet_cap { 41 let cap = match ctx.config.snippet_cap {
45 Some(it) => it, 42 Some(it) => it,
46 None => return, 43 None => return,
47 }; 44 };
48 let try_enum = TryEnum::from_ty(&ctx.sema, &receiver_ty); 45 let try_enum = TryEnum::from_ty(&ctx.sema, &ref_removed_ty);
49 if let Some(try_enum) = &try_enum { 46 if let Some(try_enum) = &try_enum {
50 match try_enum { 47 match try_enum {
51 TryEnum::Result => { 48 TryEnum::Result => {
@@ -91,7 +88,7 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
91 .add_to(acc); 88 .add_to(acc);
92 } 89 }
93 } 90 }
94 } else if !ref_removed && (receiver_ty.is_bool() || receiver_ty.is_unknown()) { 91 } else if receiver_ty.is_bool() || receiver_ty.is_unknown() {
95 postfix_snippet( 92 postfix_snippet(
96 ctx, 93 ctx,
97 cap, 94 cap,