Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints/fn_lifetime_fn.rs')
-rw-r--r--crates/ide/src/inlay_hints/fn_lifetime_fn.rs30
1 files changed, 27 insertions, 3 deletions
diff --git a/crates/ide/src/inlay_hints/fn_lifetime_fn.rs b/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
index 1f5bcea63a..2aa5e3dc73 100644
--- a/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
+++ b/crates/ide/src/inlay_hints/fn_lifetime_fn.rs
@@ -59,9 +59,14 @@ pub(super) fn hints(
r.amp_token(),
lifetime,
is_elided,
- ))
+ ));
+ false
}
- _ => (),
+ ast::Type::FnPtrType(_) => true,
+ ast::Type::PathType(t) => {
+ t.path().and_then(|it| it.segment()).and_then(|it| it.param_list()).is_some()
+ }
+ _ => false,
})
});
acc
@@ -146,8 +151,13 @@ pub(super) fn hints(
is_trivial = false;
acc.push(mk_lt_hint(amp, output_lt.to_string()));
}
+ false
+ }
+ ast::Type::FnPtrType(_) => true,
+ ast::Type::PathType(t) => {
+ t.path().and_then(|it| it.segment()).and_then(|it| it.param_list()).is_some()
}
- _ => (),
+ _ => false,
})
}
}
@@ -298,4 +308,18 @@ impl () {
"#,
);
}
+
+ #[test]
+ fn hints_lifetimes_skip_fn_likes() {
+ check_with_config(
+ InlayHintsConfig {
+ lifetime_elision_hints: LifetimeElisionHints::Always,
+ ..TEST_CONFIG
+ },
+ r#"
+fn fn_ptr(a: fn(&()) -> &()) {}
+fn fn_trait<>(a: impl Fn(&()) -> &()) {}
+"#,
+ );
+ }
}