diff options
| author | Lukas Wirth <me@lukaswirth.dev> | 2025-06-11 10:01:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-11 10:01:01 +0000 |
| commit | 6e5439b8f928abdb97d5b06283667f315f67a8aa (patch) | |
| tree | c335d602c0034192260e0914ed0e8d469ee18b93 | |
| parent | 1f1cb5db84c9f5be3c2d2db86ec969db19ee7987 (diff) | |
| parent | ac4e3657764256fc2411ccbc0e23c451c4338107 (diff) | |
| download | rust-6e5439b8f928abdb97d5b06283667f315f67a8aa.tar.gz rust-6e5439b8f928abdb97d5b06283667f315f67a8aa.zip | |
Merge pull request #19973 from Veykril/push-ppltxvqvqmkk
fix: Hide dyn inlay hints for incomplete `impl`s
| -rw-r--r-- | src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs index 32d130503a4..cd01c075832 100644 --- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs +++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs @@ -22,9 +22,14 @@ pub(super) fn hints( let parent = paren.as_ref().and_then(|it| it.parent()).unwrap_or(parent); if ast::TypeBound::can_cast(parent.kind()) || ast::TypeAnchor::can_cast(parent.kind()) - || ast::Impl::cast(parent) - .and_then(|it| it.trait_()) - .is_some_and(|it| it.syntax() == path.syntax()) + || ast::Impl::cast(parent).is_some_and(|it| { + it.trait_().map_or( + // only show it for impl type if the impl is not incomplete, otherwise we + // are likely typing a trait impl + it.assoc_item_list().is_none_or(|it| it.l_curly_token().is_none()), + |trait_| trait_.syntax() == path.syntax(), + ) + }) { return None; } @@ -85,6 +90,7 @@ impl T {} // ^ dyn impl T for (T) {} // ^^^ dyn +impl T "#, ); } |
