Skip to content

Commit 3931afa

Browse files
Don't show dyn hint in a HRTB bound
1 parent 3816d0a commit 3931afa

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

crates/ide/src/inlay_hints/implied_dyn_trait.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ pub(super) fn hints(
1717
let parent = path.syntax().parent()?;
1818
let range = match path {
1919
Either::Left(path) => {
20-
let paren =
21-
parent.ancestors().take_while(|it| ast::ParenType::can_cast(it.kind())).last();
20+
let paren = parent
21+
.ancestors()
22+
.take_while(|it| {
23+
ast::ParenType::can_cast(it.kind()) || ast::ForType::can_cast(it.kind())
24+
})
25+
.last();
2226
let parent = paren.as_ref().and_then(|it| it.parent()).unwrap_or(parent);
2327
if ast::TypeBound::can_cast(parent.kind())
2428
|| ast::TypeAnchor::can_cast(parent.kind())
@@ -136,4 +140,15 @@ fn foo(
136140
"#]],
137141
);
138142
}
143+
144+
#[test]
145+
fn hrtb_bound_does_not_add_dyn() {
146+
check(
147+
r#"
148+
//- minicore: fn
149+
fn test<F>(f: F) where F: for<'a> FnOnce(&'a i32) {}
150+
// ^: Sized
151+
"#,
152+
);
153+
}
139154
}

0 commit comments

Comments
 (0)