Repository: intellij-rust/intellij-rust
Issue: Struct initialization with Self keyword does not invoke "Create field" option 

<!--
Hello and thank you for the issue!
If you would like to report a bug, we have added some points below that you can fill out.
Feel free to remove all the irrelevant text to request a new feature.
-->

## Environment

* **IntelliJ Rust plugin version:** 0.4.183.4980-223-nightly
* **Rust toolchain version:** 1.64.0 (a55dd71d5 2022-09-19) x86_64-apple-darwin
* **IDE name and version:** CLion 2022.3 EAP (CL-223.7255.15)
* **Operating system:** macOS 12.5.1
* **Macro expansion:** enabled
* **Additional experimental features:** org.rust.cargo.features.settings.gutter, org.rust.cargo.emulate.terminal, org.rust.macros.proc.function-like, org.rust.macros.proc


Originally posted in https://youtrack.jetbrains.com/issue/CPP-30924/Rust-Struct-initialization-with-Self-keyword-does-not-invoke-Create-field-option 

## Problem description
When you attempt to initialize a struct with the Self keyword, CLion does not offer the Create field option as it does when you explicitly use the struct's own name.

## Steps to reproduce
```rust
struct A { }
impl A {
    fn new() -> A {
        let x = 0;
        A {
            x // <- invokes "Create field" option
        }
    }
    
    fn new2() -> A {
        let x = 0;
        Self {
            x // <- does not invoke "Create field" option
        }
    }
}

```

<!--
Please include as much of your codebase as needed to reproduce the error.
If the relevant files are large, please provide a link to a public repository or a [Gist](https://gist.github.com/).
-->

Changed files:
src/test/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFixTest.kt
src/main/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFix.kt

diff --git a/src/main/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFix.kt b/src/main/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFix.kt
index 9784e830b..82a4764b5 100644
--- a/src/main/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFix.kt
+++ b/src/main/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFix.kt
@@ -14,6 +14,7 @@ import com.intellij.psi.PsiFile
 import org.rust.lang.core.psi.*
 import org.rust.lang.core.psi.ext.RsVisibility
 import org.rust.lang.core.psi.ext.parentStructLiteral
+import org.rust.lang.core.resolve.ref.deepResolve
 import org.rust.lang.core.types.infer.TypeVisitor
 import org.rust.lang.core.types.regions.ReStatic
 import org.rust.lang.core.types.regions.Region
@@ -71,7 +72,7 @@ class CreateStructFieldFromConstructorFix private constructor(
         }
 
         private fun RsStructLiteralField.resolveToStructItem(): RsStructItem? {
-            return parentStructLiteral.path.reference?.resolve() as? RsStructItem
+            return parentStructLiteral.path.reference?.deepResolve() as? RsStructItem
         }
 
         private fun canUse(ty: Ty): Boolean {
diff --git a/src/test/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFixTest.kt b/src/test/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFixTest.kt
index 53a5f22cc..95edc0cb4 100644
--- a/src/test/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFixTest.kt
+++ b/src/test/kotlin/org/rust/ide/annotator/fixes/CreateStructFieldFromConstructorFixTest.kt
@@ -94,6 +94,27 @@ class CreateStructFieldFromConstructorFixTest : RsAnnotatorTestBase(RsExpression
         }
     """)
 
+    fun `test struct referenced via Self`() = checkFixByTextWithoutHighlighting("Create field", """
+        struct Foo {}
+        impl Foo {
+            fn new() -> Foo {
+                Self {
+                    /*caret*/field: 0,
+                }
+            }
+        }
+    """, """
+        struct Foo {
+            field: i32,
+        }
+        impl Foo {
+            fn new() -> Foo {
+                Self {
+                    /*caret*/field: 0,
+                }
+            }
+        }
+    """)
 
     fun `test no block`() = checkFixByText("Create field", """
         struct S;