Repository: intellij-rust/intellij-rust
Issue: rename local var cause incorrect rename in constructor

## Environment

* **IntelliJ Rust plugin version:** 0.4.175.4772-222
* **Rust toolchain version:** 1.64.0-nightly
* **IDE name and version:** CLion CL-223.1697
* **Operating system:** Manjaro

## Problem description
[rust-rename.webm](https://user-images.githubusercontent.com/8149366/181058464-287b4e3e-787b-4a58-b51d-7e978b25f693.webm)
Rename refactoring does smth strange and incorrect - it misses field name and local var name in constructor.

## Reproducer
```rust
struct Foo {
    pub bar: f32
}

fn foobar() -> Foo {
    static bar: f32 = 0.;
    Foo {
        bar
    }
}
```
> Static constant `bar` should have an upper case name such as `BAR`
rename to `BAR`

Changed files:
src/main/kotlin/org/rust/ide/refactoring/RsRenameProcessor.kt, src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt

diff --git a/src/main/kotlin/org/rust/ide/refactoring/RsRenameProcessor.kt b/src/main/kotlin/org/rust/ide/refactoring/RsRenameProcessor.kt
index 2f4958560..e7d5e2e24 100644
--- a/src/main/kotlin/org/rust/ide/refactoring/RsRenameProcessor.kt
+++ b/src/main/kotlin/org/rust/ide/refactoring/RsRenameProcessor.kt
@@ -83,15 +83,15 @@ class RsRenameProcessor : RenamePsiElementProcessor() {
         listener: RefactoringElementListener?
     ) {
         val psiFactory = RsPsiFactory(element.project)
-        if (element is RsPatBinding) {
-            usages.forEach {
-                val field = it.element?.ancestorOrSelf<RsStructLiteralField>(RsBlock::class.java) ?: return@forEach
+        if (element !is RsNamedFieldDecl) {
+            for (usage in usages) {
+                val field = usage.element?.ancestorOrSelf<RsStructLiteralField>(RsBlock::class.java) ?: continue
                 when {
                     field.isShorthand -> {
-                        val newPatField = psiFactory.createStructLiteralField(element.text, newName)
+                        val newPatField = psiFactory.createStructLiteralField(field.referenceName, newName)
                         field.replace(newPatField)
                     }
-                    field.referenceName == newName && field.expr is RsPathExpr -> {
+                    field.referenceName == newName && (field.expr as? RsPathExpr)?.path == usage.element -> {
                         field.expr?.delete()
                         field.colon?.delete()
                     }
diff --git a/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt b/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt
index ff60c3332..2d76147e8 100644
--- a/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt
+++ b/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt
@@ -614,6 +614,34 @@ class RenameTest : RsTestBase() {
         fn foo(value: u32) -> u32 { unimplemented!() }
     """)
 
+    fun `test can't use initialization shorthand after rename 3`() = doTest("value2", """
+        struct Foo { value: u32 }
+        fn bar() -> Foo {
+            const /*caret*/value: i32 = 1;
+            Foo { value }
+        }
+    """, """
+        struct Foo { value: u32 }
+        fn bar() -> Foo {
+            const value2: i32 = 1;
+            Foo { value: value2 }
+        }
+    """)
+
+    fun `test can't use initialization shorthand after rename 4`() = doTest("value2", """
+        struct Foo<T> { value: T }
+        fn bar() -> Foo {
+            fn /*caret*/value() {}
+            Foo { value }
+        }
+    """, """
+        struct Foo<T> { value: T }
+        fn bar() -> Foo {
+            fn value2() {}
+            Foo { value: value2 }
+        }
+    """)
+
     fun `test rename variable with variable conflict`() = doTestWithConflicts("a", """
         fn test() {
             let a = 1;