Put dyn inlay hints in their correct place in presence of parentheses

This commit is contained in:
Chayim Refael Friedman 2025-07-09 19:33:47 +03:00
parent 3931afa624
commit a8e67dffca

View file

@ -38,7 +38,7 @@ pub(super) fn hints(
return None; return None;
} }
sema.resolve_trait(&path.path()?)?; sema.resolve_trait(&path.path()?)?;
paren.map_or_else(|| path.syntax().text_range(), |it| it.text_range()) path.syntax().text_range()
} }
Either::Right(dyn_) => { Either::Right(dyn_) => {
if dyn_.dyn_token().is_some() { if dyn_.dyn_token().is_some() {
@ -93,7 +93,7 @@ fn foo(_: &T, _: for<'a> T) {}
impl T {} impl T {}
// ^ dyn // ^ dyn
impl T for (T) {} impl T for (T) {}
// ^^^ dyn // ^ dyn
impl T impl T
"#, "#,
); );
@ -116,7 +116,7 @@ fn foo(
_: &mut (T + T) _: &mut (T + T)
// ^^^^^ dyn // ^^^^^ dyn
_: *mut (T), _: *mut (T),
// ^^^ dyn // ^ dyn
) {} ) {}
"#, "#,
); );
@ -151,4 +151,15 @@ fn test<F>(f: F) where F: for<'a> FnOnce(&'a i32) {}
"#, "#,
); );
} }
#[test]
fn with_parentheses() {
check(
r#"
trait T {}
fn foo(v: &(T)) {}
// ^ dyn
"#,
);
}
} }