aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/lifetime.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-27 02:47:20 +0100
committerLukas Wirth <[email protected]>2021-05-27 02:47:20 +0100
commit30948e1ecb2fb4fe35bf9c5c1e49464d4ea1d064 (patch)
tree3192e07f5e0bd772e47f65be732fa8fd590b3e8b /crates/ide_completion/src/completions/lifetime.rs
parent6ec4ea8d9eb9ad6ad8b91968bde09121b5b791a0 (diff)
simplify
Diffstat (limited to 'crates/ide_completion/src/completions/lifetime.rs')
-rw-r--r--crates/ide_completion/src/completions/lifetime.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/ide_completion/src/completions/lifetime.rs b/crates/ide_completion/src/completions/lifetime.rs
index 5eeddf7a4..5f6285b84 100644
--- a/crates/ide_completion/src/completions/lifetime.rs
+++ b/crates/ide_completion/src/completions/lifetime.rs
@@ -8,19 +8,24 @@ pub(crate) fn complete_lifetime(acc: &mut Completions, ctx: &CompletionContext)
8 if !ctx.lifetime_allowed { 8 if !ctx.lifetime_allowed {
9 return; 9 return;
10 } 10 }
11 let lp_string;
11 let param_lifetime = match ( 12 let param_lifetime = match (
12 &ctx.lifetime_syntax, 13 &ctx.lifetime_syntax,
13 ctx.lifetime_param_syntax.as_ref().and_then(|lp| lp.lifetime()), 14 ctx.lifetime_param_syntax.as_ref().and_then(|lp| lp.lifetime()),
14 ) { 15 ) {
15 (Some(lt), Some(lp)) if lp == lt.clone() => return, 16 (Some(lt), Some(lp)) if lp == lt.clone() => return,
16 (Some(_), Some(lp)) => Some(lp.to_string()), 17 (Some(_), Some(lp)) => {
18 lp_string = lp.to_string();
19 Some(&lp_string)
20 }
17 _ => None, 21 _ => None,
18 }; 22 };
19 23
20 ctx.scope.process_all_names(&mut |name, res| { 24 ctx.scope.process_all_names(&mut |name, res| {
21 if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { 25 if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res {
22 if param_lifetime != Some(name.to_string()) { 26 let name = name.to_string();
23 acc.add_resolution(ctx, name.to_string(), &res); 27 if param_lifetime != Some(&name) {
28 acc.add_resolution(ctx, name, &res);
24 } 29 }
25 } 30 }
26 }); 31 });