diff options
Diffstat (limited to 'crates/ide_completion/src/completions/lifetime.rs')
-rw-r--r-- | crates/ide_completion/src/completions/lifetime.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/ide_completion/src/completions/lifetime.rs b/crates/ide_completion/src/completions/lifetime.rs index 5eeddf7a4..8ccccb646 100644 --- a/crates/ide_completion/src/completions/lifetime.rs +++ b/crates/ide_completion/src/completions/lifetime.rs | |||
@@ -8,19 +8,23 @@ 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 | if param_lifetime != Some(&*name.to_string()) { |
23 | acc.add_resolution(ctx, name.to_string(), &res); | 27 | acc.add_resolution(ctx, name, &res); |
24 | } | 28 | } |
25 | } | 29 | } |
26 | }); | 30 | }); |
@@ -36,7 +40,7 @@ pub(crate) fn complete_label(acc: &mut Completions, ctx: &CompletionContext) { | |||
36 | } | 40 | } |
37 | ctx.scope.process_all_names(&mut |name, res| { | 41 | ctx.scope.process_all_names(&mut |name, res| { |
38 | if let ScopeDef::Label(_) = res { | 42 | if let ScopeDef::Label(_) = res { |
39 | acc.add_resolution(ctx, name.to_string(), &res); | 43 | acc.add_resolution(ctx, name, &res); |
40 | } | 44 | } |
41 | }); | 45 | }); |
42 | } | 46 | } |