From e4e9404ea24b92b1bdedc19117dbaa5f3c19510d Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Wed, 9 Jul 2025 19:19:51 +0300 Subject: Don't show `dyn` hint in a HRTB bound --- .../crates/ide/src/inlay_hints/implied_dyn_trait.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/tools/rust-analyzer') 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 cd01c075832..6fc534b9f0b 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 @@ -17,8 +17,12 @@ pub(super) fn hints( let parent = path.syntax().parent()?; let range = match path { Either::Left(path) => { - let paren = - parent.ancestors().take_while(|it| ast::ParenType::can_cast(it.kind())).last(); + let paren = parent + .ancestors() + .take_while(|it| { + ast::ParenType::can_cast(it.kind()) || ast::ForType::can_cast(it.kind()) + }) + .last(); 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()) @@ -136,4 +140,15 @@ fn foo( "#]], ); } + + #[test] + fn hrtb_bound_does_not_add_dyn() { + check( + r#" +//- minicore: fn +fn test(f: F) where F: for<'a> FnOnce(&'a i32) {} + // ^: Sized + "#, + ); + } } -- cgit 1.4.1-3-g733a5