Fix incorrect dyn hint in `impl Trait for`

Example
---
```rust
trait T {}
impl T for {}
```

**Before this PR**

```rust
trait T {}
impl T for {}
  // ^ dyn
```

**After this PR**

```rust
trait T {}
impl T for {}
```
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 4fbc88a..ac91da9 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
@@ -105,6 +105,7 @@ impl T {}
   // ^ dyn
 impl T for (T) {}
          // ^ dyn
+impl T for {}
 impl T
 "#,
         );
diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
index 3357b25..76cfea9 100644
--- a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
+++ b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
@@ -447,24 +447,23 @@ pub fn remove_unnecessary_braces(mut self) {
 
 impl ast::Impl {
     pub fn self_ty(&self) -> Option<ast::Type> {
-        match self.target() {
-            (Some(t), None) | (_, Some(t)) => Some(t),
-            _ => None,
-        }
+        self.target().1
     }
 
     pub fn trait_(&self) -> Option<ast::Type> {
-        match self.target() {
-            (Some(t), Some(_)) => Some(t),
-            _ => None,
-        }
+        self.target().0
     }
 
     fn target(&self) -> (Option<ast::Type>, Option<ast::Type>) {
-        let mut types = support::children(self.syntax());
-        let first = types.next();
-        let second = types.next();
-        (first, second)
+        let mut types = support::children(self.syntax()).peekable();
+        let for_kw = self.for_token();
+        let trait_ = types.next_if(|trait_: &ast::Type| {
+            for_kw.is_some_and(|for_kw| {
+                trait_.syntax().text_range().start() < for_kw.text_range().start()
+            })
+        });
+        let self_ty = types.next();
+        (trait_, self_ty)
     }
 
     pub fn for_trait_name_ref(name_ref: &ast::NameRef) -> Option<ast::Impl> {