Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints/bind_pat.rs')
| -rw-r--r-- | crates/ide/src/inlay_hints/bind_pat.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ide/src/inlay_hints/bind_pat.rs b/crates/ide/src/inlay_hints/bind_pat.rs index 01a1a4545c..c2986a9aa6 100644 --- a/crates/ide/src/inlay_hints/bind_pat.rs +++ b/crates/ide/src/inlay_hints/bind_pat.rs @@ -36,6 +36,9 @@ pub(super) fn hints( if it.ty().is_some() { return None; } + if config.hide_closure_parameter_hints && it.syntax().ancestors().nth(2).is_none_or(|n| matches!(ast::Expr::cast(n), Some(ast::Expr::ClosureExpr(_)))) { + return None; + } Some(it.colon_token()) }, ast::LetStmt(it) => { @@ -950,6 +953,36 @@ fn bar(f: impl FnOnce(u8) -> u8) -> impl FnOnce(u8) -> u8 { } #[test] + fn skip_closure_parameter_hints() { + check_with_config( + InlayHintsConfig { + type_hints: true, + hide_closure_parameter_hints: true, + ..DISABLED_CONFIG + }, + r#" +//- minicore: fn +struct Foo; +impl Foo { + fn foo(self: Self) {} + fn bar(self: &Self) {} +} +fn main() { + let closure = |x, y| x + y; + // ^^^^^^^ impl Fn(i32, i32) -> {unknown} + closure(2, 3); + let point = (10, 20); + // ^^^^^ (i32, i32) + let (x, y) = point; + // ^ i32 ^ i32 + Foo::foo(Foo); + Foo::bar(&Foo); +} +"#, + ); + } + + #[test] fn hint_truncation() { check_with_config( InlayHintsConfig { max_length: Some(8), ..TEST_CONFIG }, |