Don't show dyn hint in a HRTB bound

This commit is contained in:
Chayim Refael Friedman 2025-07-09 19:19:51 +03:00
parent 3816d0ae53
commit 3931afa624

View file

@ -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: F) where F: for<'a> FnOnce(&'a i32) {}
// ^: Sized
"#,
);
}
}