Skip to content

Commit f7b7db8

Browse files
authored
Merge pull request #19973 from Veykril/push-ppltxvqvqmkk
fix: Hide dyn inlay hints for incomplete `impl`s
2 parents 5919f6d + 4cf958c commit f7b7db8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crates/ide/src/inlay_hints/implied_dyn_trait.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ pub(super) fn hints(
2222
let parent = paren.as_ref().and_then(|it| it.parent()).unwrap_or(parent);
2323
if ast::TypeBound::can_cast(parent.kind())
2424
|| ast::TypeAnchor::can_cast(parent.kind())
25-
|| ast::Impl::cast(parent)
26-
.and_then(|it| it.trait_())
27-
.is_some_and(|it| it.syntax() == path.syntax())
25+
|| ast::Impl::cast(parent).is_some_and(|it| {
26+
it.trait_().map_or(
27+
// only show it for impl type if the impl is not incomplete, otherwise we
28+
// are likely typing a trait impl
29+
it.assoc_item_list().is_none_or(|it| it.l_curly_token().is_none()),
30+
|trait_| trait_.syntax() == path.syntax(),
31+
)
32+
})
2833
{
2934
return None;
3035
}
@@ -85,6 +90,7 @@ impl T {}
8590
// ^ dyn
8691
impl T for (T) {}
8792
// ^^^ dyn
93+
impl T
8894
"#,
8995
);
9096
}

0 commit comments

Comments
 (0)