From 30948e1ecb2fb4fe35bf9c5c1e49464d4ea1d064 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 27 May 2021 03:47:20 +0200 Subject: simplify --- crates/ide_completion/src/completions/lifetime.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'crates/ide_completion/src/completions/lifetime.rs') 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) if !ctx.lifetime_allowed { return; } + let lp_string; let param_lifetime = match ( &ctx.lifetime_syntax, ctx.lifetime_param_syntax.as_ref().and_then(|lp| lp.lifetime()), ) { (Some(lt), Some(lp)) if lp == lt.clone() => return, - (Some(_), Some(lp)) => Some(lp.to_string()), + (Some(_), Some(lp)) => { + lp_string = lp.to_string(); + Some(&lp_string) + } _ => None, }; ctx.scope.process_all_names(&mut |name, res| { if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { - if param_lifetime != Some(name.to_string()) { - acc.add_resolution(ctx, name.to_string(), &res); + let name = name.to_string(); + if param_lifetime != Some(&name) { + acc.add_resolution(ctx, name, &res); } } }); -- cgit v1.2.3