Repository: intellij-rust/intellij-rust
Issue: Applying linter suggestion removes valid code

<!--
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.165.4438-213
* **Rust toolchain version:** 1.60.0-nightly (a00e130da 2022-01-29) x86_64-pc-windows-msvc
* **IDE name and version:** CLion 2021.3.3 (CL-213.6777.58)
* **Operating system:** Windows 10 10.0
* **Macro expansion engine:** new
* **Name resolution engine:** new
* **Additional experimental features:** org.rust.cargo.evaluate.build.scripts, org.rust.macros.proc

## Problem description

Running clippy and applying suggestion with certain lint leads to code destruction.

## Steps to reproduce

Run clippy on:

```
pub fn generate(
        &self,
        configuration: &BiomeGenerationConfiguration,
        width: usize,
        height: usize,
    ) -> Array2D<Tile> {
        let mut tiles = Array2D::filled_with(configuration.base_tile, height, width);
        tiles
    }
```

The result will be:

`Returning the result of a let binding from a block`

After applying suggestion:

```
pub fn generate(
        &self,
        configuration: &BiomeGenerationConfiguration,
        width: usize,
        height: usize,
    ) -> Array2D<Tile> {
        
        tiles
    }
```

<!--
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/ApplySuggestionFixTest.kt, src/main/kotlin/org/rust/ide/annotator/RsExternalLinterUtils.kt

diff --git a/src/main/kotlin/org/rust/ide/annotator/RsExternalLinterUtils.kt b/src/main/kotlin/org/rust/ide/annotator/RsExternalLinterUtils.kt
index 8ed20707f..84944fa98 100644
--- a/src/main/kotlin/org/rust/ide/annotator/RsExternalLinterUtils.kt
+++ b/src/main/kotlin/org/rust/ide/annotator/RsExternalLinterUtils.kt
@@ -5,7 +5,6 @@
 
 package org.rust.ide.annotator
 
-import com.intellij.execution.ExecutionException
 import com.intellij.lang.annotation.AnnotationHolder
 import com.intellij.lang.annotation.HighlightSeverity
 import com.intellij.openapi.Disposable
@@ -292,7 +291,7 @@ private fun RustcMessage.collectQuickFixes(file: PsiFile, document: Document): L
     val quickFixes = mutableListOf<ApplySuggestionFix>()
 
     fun go(message: RustcMessage) {
-        val span = message.spans.firstOrNull { it.is_primary && it.isValid() }
+        val span = message.spans.singleOrNull { it.is_primary && it.isValid() }
         createQuickFix(file, document, span, message.message)?.let { quickFixes.add(it) }
         message.children.forEach(::go)
     }
diff --git a/src/test/kotlin/org/rust/ide/annotator/fixes/ApplySuggestionFixTest.kt b/src/test/kotlin/org/rust/ide/annotator/fixes/ApplySuggestionFixTest.kt
index 29be6ab49..9e005ea0d 100644
--- a/src/test/kotlin/org/rust/ide/annotator/fixes/ApplySuggestionFixTest.kt
+++ b/src/test/kotlin/org/rust/ide/annotator/fixes/ApplySuggestionFixTest.kt
@@ -87,6 +87,14 @@ class ApplySuggestionFixTest : RsWithToolchainTestBase() {
         <error>fn foo() -> Option<i32> { Some(1) }</error>
     """, externalLinter = ExternalLinter.CLIPPY)
 
+    fun `test multi-primary fix suggestion`() = checkFixIsUnavailable("""
+        #[deny(clippy::let_and_return)]
+        fn _foo() -> i32 {
+            let x = 42;
+            <error>x</error>
+        }
+    """, externalLinter = ExternalLinter.CLIPPY)
+
     private fun checkFixByText(
         @Language("Rust") before: String,
         @Language("Rust") after: String,