anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: intellij-rust/intellij-rust
Issue: Rust Plugin Recompiles Everything Even With No Changes

## Environment

* **IntelliJ Rust plugin version:** 0.4.192.5324-231
* **Rust toolchain version:** 1.68.2 (9eb3afe9e 2023-03-27) x86_64-unknown-linux-gnu
* **IDE name and version:** CLion 2023.1.1 (CL-231.8109.222)
* **Operating system:** Linux 6.2.6-76060206-generic
* **Macro expansion:** enabled
* **Additional experimental features:** org.rust.cargo.features.settings.gutter, org.rust.cargo.emulate.terminal, org.rust.macros.proc

## Problem description
Rust plugin recompiles the entire project every time, even if no changes are made

## Steps to reproduce
1/ Create a workspace with multiple sub-projects.
2/ I also have build.rs scripts that generate grpc clients and servers via tonic.
3/ Build the project.
4/ Change nothing.
5/ Build the project again.
6/ Observe that the plugin builds everything from scratch again.
7/ Observe that if you run `cargo build` from the command line, this behavior is not exhibited.

Changed files:
src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildTaskRunner.kt

diff --git a/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildTaskRunner.kt b/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildTaskRunner.kt
index 4970332f2..9c09f3fe7 100644
--- a/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildTaskRunner.kt
+++ b/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildTaskRunner.kt
@@ -150,7 +150,7 @@ class CargoBuildTaskRunner : ProjectTaskRunner() {
             val configuration = settings.configuration as? CargoCommandConfiguration ?: return@mapNotNull null
             configuration.emulateTerminal = false
             val buildableElement = CargoBuildConfiguration(configuration, environment)
-            ProjectModelBuildTaskImpl(buildableElement, false)
+            ProjectModelBuildTaskImpl(buildableElement, task.isIncrementalBuild)
         }
     }
Repository: intellij-rust/intellij-rust
Issue: Invalid error report: unresolved reference

## Environment

* **Intellij-Rust plugin version: 0.2.0.2105-182**
* **Rust toolchain version: rustc 1.28.0 (9634041f0 2018-07-30)**
* **IDE name and version: CLion 2018.2.3**
* **Operating system: Ubuntu 18.04**

## Problem description

Invalid error report.

## Steps to reproduce

```rust
use self::E::A;

enum E {
    A { a: u32 },
}

fn make_e() -> E {
    A { a: 10 }
}
```

Unresolved reference: `A`


Changed files:
src/test/kotlin/org/rust/lang/core/resolve/RsResolveTest.kt, src/main/kotlin/org/rust/lang/core/resolve/Namespace.kt

diff --git a/src/main/kotlin/org/rust/lang/core/resolve/Namespace.kt b/src/main/kotlin/org/rust/lang/core/resolve/Namespace.kt
index 069231b0e..08340df7f 100644
--- a/src/main/kotlin/org/rust/lang/core/resolve/Namespace.kt
+++ b/src/main/kotlin/org/rust/lang/core/resolve/Namespace.kt
@@ -35,8 +35,9 @@ val RsNamedElement.namespaces: Set<Namespace> get() = when (this) {
 
     is RsPatBinding,
     is RsConstant,
-    is RsFunction,
-    is RsEnumVariant -> VALUES
+    is RsFunction -> VALUES
+
+    is RsEnumVariant -> if (blockFields == null) VALUES else TYPES
 
     is RsStructItem -> if (blockFields == null) TYPES_N_VALUES else TYPES
 
diff --git a/src/test/kotlin/org/rust/lang/core/resolve/RsResolveTest.kt b/src/test/kotlin/org/rust/lang/core/resolve/RsResolveTest.kt
index 96f60d32a..9c03a6e0a 100644
--- a/src/test/kotlin/org/rust/lang/core/resolve/RsResolveTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/resolve/RsResolveTest.kt
@@ -523,6 +523,20 @@ class RsResolveTest : RsResolveTestBase() {
                     //^ unresolved
     """)
 
+    fun `test enum variant 3`() = checkByCode("""
+        use E::A;
+
+        enum E {
+            A { a: u32 },
+          //X
+        }
+
+        fn main() {
+            let e = A { a: 10 };
+                  //^
+        }
+    """)
+
     // Enum variants behind an alias are not resolved
     // https://github.com/rust-lang/rust/issues/26264
     // https://github.com/rust-lang/rfcs/issues/2218
Repository: intellij-rust/intellij-rust
Issue: Usage of 'Self' should not display deprecation warning

## Environment

* **IntelliJ Rust plugin version:** 0.2.108.2143-193
* **Rust toolchain version:** rustc 1.38.0
* **IDE name and version:** IDEA Ultimate 2019.3 EAP
* **Operating system:** Arch Linux

## Problem description
The following example should not cause a deprecation inspection to appear; `Self` is only part of the trait definition and should not count as "usage".

## Steps to reproduce
```
#[deprecated(note = "Ni!")]
trait Knight {
    fn new() -> Self;
    //          ^^^^ `Self` is deprecated: Ni!
}
```


Changed files:
src/main/kotlin/org/rust/ide/inspections/RsDeprecationInspection.kt, src/test/kotlin/org/rust/ide/inspections/RsDeprecationInspectionTest.kt

diff --git a/src/main/kotlin/org/rust/ide/inspections/RsDeprecationInspection.kt b/src/main/kotlin/org/rust/ide/inspections/RsDeprecationInspection.kt
index b4fa0b494..17eb761cf 100644
--- a/src/main/kotlin/org/rust/ide/inspections/RsDeprecationInspection.kt
+++ b/src/main/kotlin/org/rust/ide/inspections/RsDeprecationInspection.kt
@@ -8,6 +8,7 @@ package org.rust.ide.inspections
 import com.intellij.codeInspection.ProblemHighlightType.LIKE_DEPRECATED
 import com.intellij.psi.PsiElement
 import com.intellij.psi.PsiElementVisitor
+import org.rust.lang.core.psi.RsElementTypes.CSELF
 import org.rust.lang.core.psi.RsFile
 import org.rust.lang.core.psi.RsMetaItem
 import org.rust.lang.core.psi.RsModDeclItem
@@ -27,6 +28,9 @@ class RsDeprecationInspection : RsLintInspection() {
             val original = ref.reference?.resolve() ?: return
             val identifier = ref.referenceNameElement ?: return
 
+            // ignore `Self` identifier
+            if (identifier.elementType == CSELF) return
+
             val targetElement = when (original) {
                 is RsFile -> original.declaration
                 is RsAbstractable -> if (original.owner.isTraitImpl) original.superItem else original
diff --git a/src/test/kotlin/org/rust/ide/inspections/RsDeprecationInspectionTest.kt b/src/test/kotlin/org/rust/ide/inspections/RsDeprecationInspectionTest.kt
index e5c867649..e757fb920 100644
--- a/src/test/kotlin/org/rust/ide/inspections/RsDeprecationInspectionTest.kt
+++ b/src/test/kotlin/org/rust/ide/inspections/RsDeprecationInspectionTest.kt
@@ -352,4 +352,10 @@ class RsDeprecationInspectionTest : RsInspectionsTestBase(RsDeprecationInspectio
         }
     """)
 
+    fun `test no warning on Self inside deprecated trait`() = checkByText("""
+        #[deprecated()]
+        trait T {
+            fn new() -> Self;
+        }
+    """)
 }
Repository: intellij-rust/intellij-rust
Issue: Incorrect "mismatched types [E0308]" error

## Environment

* **IntelliJ Rust plugin version:** 0.2.110.5731-193-dev
* **Rust toolchain version:** 1.39 stable
* **IDE name and version:** IntelliJ IDEA 2019.3 beta
* **Operating system:** Windows 10 x64

## Problem description
Plugin gives incorrect E0308. New experimental macro engine is enabled.

## Steps to reproduce

```rust
fn main() {
    eat_slice(&[]); // error highlights empty slice ref
}

fn eat_slice(slice: &[&str]) {}
```

Error is:
```
mismatched types [E0308]
expected `&[&str]`, found `&[<unknown>]`
```

Code compiles without error.

Changed files:
src/test/kotlin/org/rust/ide/inspections/typecheck/RsTypeCheckInspectionTest.kt, src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt

diff --git a/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt b/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt
index ec04e93f3..de2c5ab4a 100644
--- a/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt
+++ b/src/main/kotlin/org/rust/lang/core/types/infer/TypeInferenceWalker.kt
@@ -213,7 +213,10 @@ class RsTypeInferenceWalker(
                     TyAnon::class.java
                 )
 
-                if (result.ty1.javaClass !in ignoredTys && result.ty2.javaClass !in ignoredTys) {
+                if (result.ty1.javaClass !in ignoredTys && result.ty2.javaClass !in ignoredTys
+                    && !(expected is TyReference && inferred is TyReference
+                        && (expected.containsTyOfClass(ignoredTys) || inferred.containsTyOfClass(ignoredTys)))
+                ) {
                     // another awful hack: check that inner expressions did not annotated as an error
                     // to disallow annotation intersections. This should be done in a different way
                     if (ctx.diagnostics.all { !element.isAncestorOf(it.element) }) {
diff --git a/src/test/kotlin/org/rust/ide/inspections/typecheck/RsTypeCheckInspectionTest.kt b/src/test/kotlin/org/rust/ide/inspections/typecheck/RsTypeCheckInspectionTest.kt
index 134d1abc5..46ac2f4b2 100644
--- a/src/test/kotlin/org/rust/ide/inspections/typecheck/RsTypeCheckInspectionTest.kt
+++ b/src/test/kotlin/org/rust/ide/inspections/typecheck/RsTypeCheckInspectionTest.kt
@@ -272,4 +272,13 @@ class RsTypeCheckInspectionTest : RsInspectionsTestBase(RsTypeCheckInspection::c
             return <error>B(Unknown)</error>
         }
     """)
+
+    fun `test no type mismatch E0308 on reference coecrion of partially unknown type`() = checkByText("""
+        struct Bar;
+        fn foo(a: &Bar) {}
+        
+        fn main() {
+            foo(&Unknown);
+        }
+    """)
 }
Repository: intellij-rust/intellij-rust
Issue: Incorrect terminal size

## Environment

* **IntelliJ Rust plugin version:** 0.2.117.2170-193
* **Rust toolchain version:** 1.43.0-nightly (a1912f2e8 2020-02-12) x86_64-unknown-linux-gnu
* **IDE name and version:** CLion 2019.3.4 (CL-193.6494.38)
* **Operating system:** Linux 5.3.0-40-generic

## Problem description

Clion terminal have not correct dimentions.
Next code show size of terminal.
It work with different terminals, but not with JetBrains.
I use two crates. They work same.

## Steps to reproduce

```rust
use term_size;
use terminal_size::{Width, Height, terminal_size};

fn main() {

    if let Some((w, h)) = term_size::dimensions() {
        println!("Width: {}\\nHeight: {}", w, h);
    } else {
        println!("Unable to get term size :(")
    }


    let size = terminal_size();
    if let Some((Width(w), Height(h))) = size {
        println!("Your terminal is {} cols wide and {} lines tall", w, h);
     } else {
         println!("Unable to get terminal size");
     }

}
```

Changed files:
src/main/kotlin/org/rust/cargo/toolchain/Cargo.kt, src/main/kotlin/org/rust/cargo/toolchain/Evcxr.kt

diff --git a/src/main/kotlin/org/rust/cargo/toolchain/Cargo.kt b/src/main/kotlin/org/rust/cargo/toolchain/Cargo.kt
index 0e44cb119..c42ab0bd8 100644
--- a/src/main/kotlin/org/rust/cargo/toolchain/Cargo.kt
+++ b/src/main/kotlin/org/rust/cargo/toolchain/Cargo.kt
@@ -19,6 +19,7 @@ import com.intellij.openapi.Disposable
 import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.diagnostic.Logger
 import com.intellij.openapi.project.Project
+import com.intellij.openapi.util.SystemInfo
 import com.intellij.openapi.vfs.VirtualFile
 import com.intellij.openapiext.Testmark
 import com.intellij.util.execution.ParametersListUtil
@@ -360,7 +361,10 @@ class Cargo(private val cargoExecutable: Path) {
             }
             environmentVariables.configureCommandLine(cmdLine, true)
             return if (emulateTerminal) {
-                PtyCommandLine(cmdLine).withConsoleMode(false)
+                if (!SystemInfo.isWindows) {
+                    cmdLine.environment["TERM"] = "xterm-256color"
+                }
+                PtyCommandLine(cmdLine).withInitialColumns(PtyCommandLine.MAX_COLUMNS)
             } else {
                 cmdLine
             }
diff --git a/src/main/kotlin/org/rust/cargo/toolchain/Evcxr.kt b/src/main/kotlin/org/rust/cargo/toolchain/Evcxr.kt
index 47babee73..9a456e7b6 100644
--- a/src/main/kotlin/org/rust/cargo/toolchain/Evcxr.kt
+++ b/src/main/kotlin/org/rust/cargo/toolchain/Evcxr.kt
@@ -14,7 +14,6 @@ class Evcxr(private val evcxrExecutable: Path) {
     fun createCommandLine(workingDirectory: File): PtyCommandLine =
         PtyCommandLine()
             .withInitialColumns(PtyCommandLine.MAX_COLUMNS)
-            .withConsoleMode(true)
             .withExePath(evcxrExecutable.systemIndependentPath)
             .withParameters(
                 "--ide-mode",
Repository: intellij-rust/intellij-rust
Issue: 'cargo clippy' run configuration produces no output.

<!--
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.
Consider using "Help | Create New Issue" action that fills out all necessary information automatically.
Feel free to remove all the irrelevant text to request a new feature.
-->

## Environment

* **IntelliJ Rust plugin version:** 0.4.181.4965-222
* **Rust toolchain version:** Nightly
* **IDE name and version:**  IU-222.3739.54
* **Operating system:** WSL-2

## Problem description
 running `cargo clippy` from a cargo run configuration doesn't do anything.

## Steps to reproduce

1. create a new run configuration in a rust project. for command, simply put "clippy". turn off build before launch.
2. try to run this configuration. observe that nothing happens.

<!--
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/).

If you provide a screenshot of some code, please also copy-paste the corresponding code snippet here.
-->


Changed files:
src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt

diff --git a/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt b/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt
index ab560aa23..096f52c5d 100644
--- a/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt
+++ b/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt
@@ -64,15 +64,6 @@ object CargoBuildManager {
 
     private val MIN_RUSTC_VERSION: SemVer = "1.48.0".parseSemVer()
 
-    val RsCommandConfiguration.isBuildToolWindowEnabled: Boolean
-        get() {
-            if (!project.isBuildToolWindowAvailable) return false
-            return beforeRunTasks.any { task ->
-                task is CargoBuildTaskProvider.BuildTask ||
-                    task is WasmPackBuildTaskProvider.BuildTask
-            }
-        }
-
     val Project.isBuildToolWindowAvailable: Boolean
         get() {
             if (!isFeatureEnabled(RsExperiments.BUILD_TOOL_WINDOW)) return false
@@ -85,7 +76,8 @@ object CargoBuildManager {
     val CargoCommandConfiguration.isBuildToolWindowAvailable: Boolean
         get() {
             if (!project.isBuildToolWindowAvailable) return false
-            return !hasRemoteTarget || buildTarget.isLocal
+            val hasBuildBeforeRunTask = beforeRunTasks.any { task -> task is CargoBuildTaskProvider.BuildTask }
+            return hasBuildBeforeRunTask && (!hasRemoteTarget || buildTarget.isLocal)
         }
 
     fun build(buildConfiguration: CargoBuildConfiguration): Future<CargoBuildResult> {
Repository: intellij-rust/intellij-rust
Issue: Memory leak detected

## Environment

* **IntelliJ Rust plugin version:** 0.4.169.4544-221-nightly
* **Rust toolchain version:** 1.62.0-nightly (60e50fc1c 2022-04-04) x86_64-apple-darwin
* **IDE name and version:** IntelliJ IDEA 2022.1 Beta Ultimate Edition (IU-221.5080.93)
* **Operating system:** macOS 11.5.1
* **Macro expansion engine:** new
* **Name resolution engine:** new
* **Additional experimental features:** org.rust.cargo.features.settings.gutter, org.rust.cargo.evaluate.build.scripts, org.rust.macros.proc

## Problem description
```
2022-04-06 12:15:59,758 [5473958] SEVERE - #c.i.o.u.ObjectTree - Plugin to blame: Rust version: 0.4.169.4542-221-nightly
2022-04-06 12:15:59,758 [5473958] SEVERE - #c.i.o.u.ObjectTree - Memory leak detected: 'org.rust.cargo.project.settings.ui.RustProjectSettingsPanel@133c98d0' of class org.rust.cargo.project.settings.ui.RustProjectSettingsPanel is registered in Disposer but wasn't disposed.
Register it with a proper parentDisposable or ensure that it's always disposed by direct Disposer.dispose call.
See https://jetbrains.org/intellij/sdk/docs/basics/disposers.html for more details.
The corresponding Disposer.register() stacktrace is shown as the cause:

java.lang.RuntimeException: Memory leak detected: 'org.rust.cargo.project.settings.ui.RustProjectSettingsPanel@133c98d0' of class org.rust.cargo.project.settings.ui.RustProjectSettingsPanel is registered in Disposer but wasn't disposed.
Register it with a proper parentDisposable or ensure that it's always disposed by direct Disposer.dispose call.
See https://jetbrains.org/intellij/sdk/docs/basics/disposers.html for more details.
```

Logs:

[scratch_5.txt](https://github.com/intellij-rust/intellij-rust/files/8440573/scratch_5.txt)



Changed files:
src/main/kotlin/org/rust/cargo/project/configurable/RsProjectConfigurable.kt

diff --git a/src/main/kotlin/org/rust/cargo/project/configurable/RsProjectConfigurable.kt b/src/main/kotlin/org/rust/cargo/project/configurable/RsProjectConfigurable.kt
index 704626611..dded9dc1e 100644
--- a/src/main/kotlin/org/rust/cargo/project/configurable/RsProjectConfigurable.kt
+++ b/src/main/kotlin/org/rust/cargo/project/configurable/RsProjectConfigurable.kt
@@ -24,7 +24,9 @@ class RsProjectConfigurable(
     project: Project
 ) : RsConfigurableBase(project, RsBundle.message("settings.rust.toolchain.name")), Configurable.NoScroll {
     private val projectDir = project.cargoProjects.allProjects.firstOrNull()?.rootDir?.pathAsPath ?: Paths.get(".")
-    private val rustProjectSettings = RustProjectSettingsPanel(projectDir)
+    // TODO: move creation of the panel inside `createPanel`
+    //  and use `onIsModified`, `onApply` and `onReset` methods
+    private val rustProjectSettings by lazy { RustProjectSettingsPanel(projectDir) }
 
     override fun createPanel(): DialogPanel = panel {
         rustProjectSettings.attachTo(this)
Repository: intellij-rust/intellij-rust
Issue: False positive errors on struct pattern with raw identifiers

## Environment

* **IntelliJ Rust plugin version:**
0.2.104.2132-192

* **Rust toolchain version:**
rustc 1.37.0 (eae3437df 2019-08-13)

* **IDE name and version:**
CLion 2019.2.1 Build #CL-192.6262.62, built on August 21, 2019

* **Operating system:**
OSX

## Problem description
False positive errors on struct pattern with raw identifiers:

    Struct pattern does not correspond to its declaration [E0027]
    Extra field found in the struct pattern: 'r#type' [E0026]

## Steps to reproduce

```rust
struct Foo {
    r#type: u64
}

fn bar() {
    let Foo { r#type: _ } = Foo { r#type: 0 };
}
```


Changed files:
src/main/kotlin/org/rust/lang/core/psi/ext/RsPatField.kt, src/test/kotlin/org/rust/ide/annotator/RsErrorAnnotatorTest.kt

diff --git a/src/main/kotlin/org/rust/lang/core/psi/ext/RsPatField.kt b/src/main/kotlin/org/rust/lang/core/psi/ext/RsPatField.kt
index 72dd738eb..35d2ee808 100644
--- a/src/main/kotlin/org/rust/lang/core/psi/ext/RsPatField.kt
+++ b/src/main/kotlin/org/rust/lang/core/psi/ext/RsPatField.kt
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiElement
 import org.rust.lang.core.psi.RsPat
 import org.rust.lang.core.psi.RsPatBinding
 import org.rust.lang.core.psi.RsPatField
+import org.rust.lang.core.psi.unescapedText
 
 val RsPatField.kind: RsPatFieldKind
     get() = patBinding?.let { RsPatFieldKind.Shorthand(it, box != null) }
@@ -32,6 +33,6 @@ sealed class RsPatFieldKind {
 
 val RsPatFieldKind.fieldName: String
     get() = when (this) {
-        is RsPatFieldKind.Full -> ident.text
-        is RsPatFieldKind.Shorthand -> binding.identifier.text
+        is RsPatFieldKind.Full -> ident.unescapedText
+        is RsPatFieldKind.Shorthand -> binding.name!! // can't be null
     }
diff --git a/src/test/kotlin/org/rust/ide/annotator/RsErrorAnnotatorTest.kt b/src/test/kotlin/org/rust/ide/annotator/RsErrorAnnotatorTest.kt
index ee6359c86..fff039680 100644
--- a/src/test/kotlin/org/rust/ide/annotator/RsErrorAnnotatorTest.kt
+++ b/src/test/kotlin/org/rust/ide/annotator/RsErrorAnnotatorTest.kt
@@ -2903,4 +2903,11 @@ class RsErrorAnnotatorTest : RsAnnotatorTestBase(RsErrorAnnotator::class.java) {
             let Foo { a, } = foo;
         }
     """)
+
+    fun `test no E0026 on raw identifier field`() = checkErrors("""
+        struct Foo { r#field: u64 }
+        fn bar(f: Foo) {
+            let Foo { r#field: _ } = f;
+        }
+    """)
 }
Repository: intellij-rust/intellij-rust
Issue: Unable to debug with command line arguments when also specifying which features to use in Run/Debug Configurations.

## Environment

* **IntelliJ Rust plugin version:**  0.2.103.2131-192
* **Rust toolchain version:** 1.34.0
* **IDE name and version:** CLion 2019.2
* **Operating system:** Linux

## Problem description
It is not possible to debug applications with command line parameters when the "Command" Run/Debug Configurations field contains "--features".  Running them works fine.

Example:
I am working through ash Vulkan tutorials and wanted to implement Vulkan validation as a feature.  I also want to pass in the path to the shaders directory as an optional command line argument.  I also have `-c` as another optional command line switch.
So for example: `run --package ash_tut --bin ash_tut --features vk-validation  -- -s ./shaders -c`  
But when I use this as the "Command" field for a Cargo Run/Debug Configuration, I get the following:
```
/usr/bin/cargo build --color=always --package ash_tut --bin ash_tut --features vk-validation -- -s -c
error: Found argument '-s' which wasn't expected, or isn't valid in this context

USAGE:
    cargo build --bin <NAME>... --color <WHEN> --features <FEATURES> --package <SPEC>...

For more information try --help
```
If I remove `--features vk-validation` or my command line arguments, debug works fine.  
It also appears that my shader path has been removed from the command sent to cargo for some reason.  

Cargo.toml:
```
...
[features]
vk-validation = []
...
```

Changed files:
src/main/kotlin/org/rust/cargo/util/CargoArgsParser.kt

diff --git a/src/main/kotlin/org/rust/cargo/util/CargoArgsParser.kt b/src/main/kotlin/org/rust/cargo/util/CargoArgsParser.kt
index 07a65a072..14c930efa 100644
--- a/src/main/kotlin/org/rust/cargo/util/CargoArgsParser.kt
+++ b/src/main/kotlin/org/rust/cargo/util/CargoArgsParser.kt
@@ -44,7 +44,7 @@ class CargoArgsParser private constructor(
         val (_, maxArgsCount) = optionsToArgsCountRange.getOrDefault(option, OptionArgsCountRange.ZERO)
         return cargoArgs.asSequence()
             .drop(optionIdx + 1)
-            .takeWhile { !OPTION_NAME_RE.matches(it) }
+            .takeWhile { it != "--" && !OPTION_NAME_RE.matches(it) }
             .take(maxArgsCount)
             .count()
     }
Repository: intellij-rust/intellij-rust
Issue: Up/down mover produces an unexpected result if moved statement starts/ends with a comment

## Environment

* **Intellij-Rust plugin version:** 0.2.94.2580-191-nightly
* **Rust toolchain version:** nightly-x86_64-apple-darwin
* **Rustc version:** 1.34.0-nightly (aadbc459b 2019-02-23)
* **IDE name and version:** CLion 2019.1 Beta (191.6183.6)
* **Operating system:** macOS Mojave 10.14.3 (18D109)

## Problem description

```rust
fn main() {
    1;
    {
        2;
        /*caret*/3; // 123
        4;
    }
    5;
}
```

After move statement down:
```rust
fn main() {
    1;
    {
        2;
    5;
        /*caret*/3; // 123
        4;
    }
}
```

Changed files:
src/test/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMoverTest.kt, src/main/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMover.kt

diff --git a/src/main/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMover.kt b/src/main/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMover.kt
index d41941de6..af64b281f 100644
--- a/src/main/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMover.kt
+++ b/src/main/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMover.kt
@@ -25,8 +25,11 @@ class RsStatementUpDownMover : RsLineMover() {
     private val PsiElement.isBlockExpr: Boolean
         get() = this is RsExpr && parent is RsBlock
 
+    private val PsiElement.isComment: Boolean
+        get() = elementType in RS_COMMENTS
+
     override fun findMovableAncestor(psi: PsiElement, endpoint: RangeEndpoint): PsiElement? =
-        psi.ancestors.find { it.elementType in movableItems || it.isBlockExpr }
+        psi.ancestors.find { it.elementType in movableItems || it.isBlockExpr || it.isComment }
 
     override fun findTargetElement(sibling: PsiElement, down: Boolean): PsiElement? {
         if (isMovingOutOfFunctionBody(sibling, down)) {
diff --git a/src/test/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMoverTest.kt b/src/test/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMoverTest.kt
index 01ae4b649..b446edb2d 100644
--- a/src/test/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMoverTest.kt
+++ b/src/test/kotlin/org/rust/ide/actions/mover/RsStatementUpDownMoverTest.kt
@@ -492,4 +492,28 @@ class RsStatementUpDownMoverTest : RsStatementUpDownMoverTestBase() {
             1/*caret*/;
         }
     """)
+
+
+    // https://github.com/intellij-rust/intellij-rust/issues/3548
+    fun `test statement ends with comment`() = moveDown("""
+        fn main() {
+            1;
+            {
+                2;
+                /*caret*/3; // 123
+                4;
+            }
+            5;
+        }
+    """, """
+        fn main() {
+            1;
+            {
+                2;
+                4;
+                /*caret*/3; // 123
+            }
+            5;
+        }
+    """)
 }
Repository: intellij-rust/intellij-rust
Issue: Cannot create new project in 2023.1 eap

<!--
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.187.5158-231-nightly
* **Rust toolchain version:** 1.68.0-nightly (4781233a7 2023-01-16) x86_64-apple-darwin
* **IDE name and version:** IntelliJ IDEA 2023.1 EAP Ultimate Edition (IU-231.4840.387)
* **Operating system:** macOS 12.5.1
* **Macro expansion:** enabled
* **Additional experimental features:** org.rust.cargo.emulate.terminal

## Problem description
`creating new project` window is shown forever, after closing it by hand IDE becomes partly unclickable.
In fact, IDE creates an empty folder. 

## Steps to reproduce
Create a new project as usual


<!--
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/main/kotlin/org/rust/ide/security/RsTrustStateListener.kt

diff --git a/src/main/kotlin/org/rust/ide/security/RsTrustStateListener.kt b/src/main/kotlin/org/rust/ide/security/RsTrustStateListener.kt
index 8c86d2921..fa40fb1ec 100644
--- a/src/main/kotlin/org/rust/ide/security/RsTrustStateListener.kt
+++ b/src/main/kotlin/org/rust/ide/security/RsTrustStateListener.kt
@@ -6,6 +6,7 @@
 package org.rust.ide.security
 
 import com.intellij.ide.impl.TrustStateListener
+import com.intellij.openapi.application.runInEdt
 import com.intellij.openapi.project.Project
 import org.rust.cargo.project.model.cargoProjects
 
@@ -13,7 +14,13 @@ import org.rust.cargo.project.model.cargoProjects
 class RsTrustStateListener : TrustStateListener {
 
     override fun onProjectTrusted(project: Project) {
-        // Load project model that wasn't load before because project wasn't trusted
-        project.cargoProjects.refreshAllProjects()
+        // Since 2023.1, this callback can be called in the background thread which EDT waits for.
+        // In combination with fact that we call `invokeAndWaitIfNeeded` inside `refreshAllProjects`,
+        // it may lead to deadlock.
+        // Let's postpone invocation of `refreshAllProjects` to next event if this code is executed in background thread
+        runInEdt {
+            // Load project model that wasn't load before because project wasn't trusted
+            project.cargoProjects.refreshAllProjects()
+        }
     }
 }