Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/completions/lifetime.rs')
-rw-r--r--crates/ide_completion/src/completions/lifetime.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/ide_completion/src/completions/lifetime.rs b/crates/ide_completion/src/completions/lifetime.rs
index bc9f3913fb..233bf51ec0 100644
--- a/crates/ide_completion/src/completions/lifetime.rs
+++ b/crates/ide_completion/src/completions/lifetime.rs
@@ -8,6 +8,7 @@
//! show up for normal completions, or they won't show completions other than lifetimes depending
//! on the fixture input.
use hir::ScopeDef;
+use syntax::ast;
use crate::{completions::Completions, context::CompletionContext};
@@ -17,17 +18,15 @@ pub(crate) fn complete_lifetime(acc: &mut Completions, ctx: &CompletionContext)
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)) => {
- lp_string = lp.to_string();
- Some(&*lp_string)
- }
- _ => None,
- };
+ let param_lifetime =
+ match (&ctx.name_syntax, ctx.lifetime_param_syntax.as_ref().and_then(|lp| lp.lifetime())) {
+ (Some(ast::NameLike::Lifetime(lt)), Some(lp)) if lp == lt.clone() => return,
+ (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 {