Repository: intellij-rust/intellij-rust
Issue: Coverage is not working on a wsl system.

## Environment

* **IntelliJ Rust plugin version:** 0.4.155.4114-212
* **Rust toolchain version:** 1.55.0 (c8dfcfe04 2021-09-06) x86_64-unknown-linux-gnu
* **IDE name and version:** PyCharm 2021.2.2 Professional Edition (PY-212.5284.44)
* **Operating system:** Windows 10 10.0
* **Macro expansion engine:** new
* **Name resolution engine:** new

## Problem description

When I try to run tests with coverage support on Pycharm with the wsl feature enabled, the test run successfully but no coverage data is available in the IDE.

The complete command line executed by Pycharm is the following.
```bash
C:\\Windows\\system32\\wsl.exe --distribution Ubuntu-20.04 --exec /bin/sh -c "export PATH=\\"/home/<user>/.cargo/bin:$PATH\\" && export RUST_BACKTRACE=short && export TERM=ansi && export CARGO_INCREMENTAL=0 && export RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off' && export RUSTC_BOOTSTRAP=1 && cd /home/adrien/projects/coverage-test && /home/adrien/.cargo/bin/cargo test --color=always --package coverage-test --lib 'tests::it_works' --no-fail-fast -- --format=json --exact -Z unstable-options --show-output"
```

If I try the same thing with the 0.4.157.4136-212-nightly version of the plugin, the coverage window appears but it doesn't display any covered line. The command line is the same.


## Steps to reproduce

```rust
fn sum2(a: u32, b: u32) -> u32 {
    dbg!((a, b));
    a + b
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        assert_eq!(sum2(2, 2), 4);
    }
}
```

Changed files:
src/main/kotlin/org/rust/cargo/toolchain/tools/Cargo.kt
src/test/kotlin/org/rust/RustcVersion.kt
src/main/kotlin/org/rust/cargo/project/model/impl/CargoSyncTask.kt
src/test/kotlin/org/rustSlowTests/lang/resolve/CustomTargetCfgResolveTest.kt
src/main/kotlin/org/rust/cargo/toolchain/RsToolchainBase.kt
coverage/src/main/kotlin/org/rust/coverage/LcovCoverageReport.kt
src/test/kotlin/org/rust/cargo/toolchain/RustcVersionParsingTest.kt
src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt
src/main/kotlin/org/rust/lang/core/CompilerFeature.kt
src/test/kotlin/org/rust/cargo/runconfig/CargoTestRunStateTest.kt
src/main/kotlin/org/rust/cargo/util/ToolchainUtil.kt
src/test/kotlin/org/rust/lang/core/stubs/RsLazyBlockStubCreationTestBase.kt
src/test/kotlin/org/rust/RsTestBase.kt
src/main/kotlin/org/rust/cargo/runconfig/CargoTestRunState.kt
src/test/kotlin/org/rust/lang/core/macros/decl/RsMacroExpansionTest.kt
debugger/src/main/kotlin/org/rust/debugger/runconfig/RsDebugProcessConfigurationHelper.kt

diff --git a/coverage/src/main/kotlin/org/rust/coverage/LcovCoverageReport.kt b/coverage/src/main/kotlin/org/rust/coverage/LcovCoverageReport.kt
index 8630127b2..b41911d90 100644
--- a/coverage/src/main/kotlin/org/rust/coverage/LcovCoverageReport.kt
+++ b/coverage/src/main/kotlin/org/rust/coverage/LcovCoverageReport.kt
@@ -5,6 +5,7 @@
 
 package org.rust.coverage
 
+import com.intellij.openapi.util.io.systemIndependentPath
 import com.intellij.util.containers.PeekableIteratorWrapper
 import org.rust.stdext.buildList
 import java.io.File
@@ -18,7 +19,7 @@ class LcovCoverageReport {
         val file = File(filePath).let {
             if (it.isAbsolute || basePath == null) it else File(basePath, filePath)
         }
-        val normalizedFilePath = getNormalizedPath(file)
+        val normalizedFilePath = file.systemIndependentPath
         val oldReport = info[normalizedFilePath]
         val result = normalizeLineHitsList(report).let {
             if (oldReport == null) it else doMerge(oldReport, report)
@@ -103,17 +104,6 @@ class LcovCoverageReport {
     }
 
     companion object {
-        private const val UNIX_SEPARATOR: String = "/"
-
-        fun getNormalizedPath(file: File): String {
-            val uri = file.toURI()
-            val normalizedUri = uri.normalize()
-            var normalizedPath = normalizedUri.path
-            if (normalizedPath.startsWith(UNIX_SEPARATOR) && File.separator != UNIX_SEPARATOR) {
-                normalizedPath = normalizedPath.substring(1)
-            }
-            return normalizedPath
-        }
 
         private fun normalizeLineHitsList(lineHits: List<LineHits>): List<LineHits> =
             lineHits.sortedBy { it.lineNumber }.distinctBy { it.lineNumber }
diff --git a/debugger/src/main/kotlin/org/rust/debugger/runconfig/RsDebugProcessConfigurationHelper.kt b/debugger/src/main/kotlin/org/rust/debugger/runconfig/RsDebugProcessConfigurationHelper.kt
index ca00264f6..54f13a752 100644
--- a/debugger/src/main/kotlin/org/rust/debugger/runconfig/RsDebugProcessConfigurationHelper.kt
+++ b/debugger/src/main/kotlin/org/rust/debugger/runconfig/RsDebugProcessConfigurationHelper.kt
@@ -11,7 +11,6 @@ import com.intellij.openapi.diagnostic.logger
 import com.intellij.openapi.util.NlsContexts.NotificationContent
 import com.intellij.openapi.util.io.FileUtil
 import com.intellij.openapi.util.text.StringUtil
-import com.intellij.util.text.SemVer
 import com.jetbrains.cidr.execution.debugger.CidrDebugProcess
 import com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException
 import com.jetbrains.cidr.execution.debugger.backend.DebuggerDriver
@@ -22,6 +21,7 @@ import org.rust.cargo.project.settings.toolchain
 import org.rust.cargo.runconfig.command.workingDirectory
 import org.rust.cargo.toolchain.tools.rustc
 import org.rust.cargo.toolchain.wsl.RsWslToolchain
+import org.rust.cargo.util.parseSemVer
 import org.rust.debugger.*
 import org.rust.debugger.settings.RsDebuggerSettings
 import org.rust.ide.notifications.showBalloon
@@ -192,7 +192,7 @@ class RsDebugProcessConfigurationHelper(
         private val LOG: Logger = logger<RsDebugProcessConfigurationHelper>()
 
         // BACKCOMPAT: Rust 1.45. Drop this property
-        private val RUST_1_46 = SemVer.parseFromText("1.46.0")!!
+        private val RUST_1_46 = "1.46.0".parseSemVer()
 
         /**
          * Should be synchronized with `rust_types.py`
diff --git a/src/main/kotlin/org/rust/cargo/project/model/impl/CargoSyncTask.kt b/src/main/kotlin/org/rust/cargo/project/model/impl/CargoSyncTask.kt
index 9ae9b9365..26305f143 100644
--- a/src/main/kotlin/org/rust/cargo/project/model/impl/CargoSyncTask.kt
+++ b/src/main/kotlin/org/rust/cargo/project/model/impl/CargoSyncTask.kt
@@ -48,6 +48,7 @@ import org.rust.cargo.toolchain.impl.RustcVersion
 import org.rust.cargo.toolchain.tools.*
 import org.rust.cargo.util.DownloadResult
 import org.rust.cargo.util.UnitTestRustcCacheService
+import org.rust.cargo.util.parseSemVer
 import org.rust.openapiext.TaskResult
 import org.rust.stdext.mapNotNullToSet
 import java.nio.file.Path
@@ -507,4 +508,4 @@ private fun CargoSyncTask.SyncContext.warning(
     syncProgress.message(title, message, MessageEvent.Kind.WARNING, null)
 }
 
-private val RUST_1_51: SemVer = SemVer.parseFromText("1.51.0")!!
+private val RUST_1_51: SemVer = "1.51.0".parseSemVer()
diff --git a/src/main/kotlin/org/rust/cargo/runconfig/CargoTestRunState.kt b/src/main/kotlin/org/rust/cargo/runconfig/CargoTestRunState.kt
index 184eadd0e..eecbcb4bd 100644
--- a/src/main/kotlin/org/rust/cargo/runconfig/CargoTestRunState.kt
+++ b/src/main/kotlin/org/rust/cargo/runconfig/CargoTestRunState.kt
@@ -14,7 +14,6 @@ import com.intellij.execution.runners.ProgramRunner
 import com.intellij.execution.testframework.autotest.ToggleAutoTestAction
 import com.intellij.notification.NotificationType
 import com.intellij.openapi.util.SystemInfo
-import com.intellij.util.text.SemVer
 import org.rust.RsBundle
 import org.rust.cargo.runconfig.buildtool.CargoPatch
 import org.rust.cargo.runconfig.command.CargoCommandConfiguration
@@ -22,6 +21,7 @@ import org.rust.cargo.runconfig.console.CargoTestConsoleBuilder
 import org.rust.cargo.toolchain.CargoCommandLine
 import org.rust.cargo.toolchain.RustChannel
 import org.rust.cargo.toolchain.impl.RustcVersion
+import org.rust.cargo.util.parseSemVer
 import org.rust.ide.notifications.showBalloon
 import java.time.LocalDate
 
@@ -89,7 +89,7 @@ class CargoTestRunState(
         private fun checkShowOutputSupport(ver: RustcVersion?): Boolean {
             if (ver == null) return false
             // --show-output is supported since 1.39.0-nightly/dev with a build date later than 2019-08-27
-            val minRelease = SemVer.parseFromText("1.39.0")
+            val minRelease = "1.39.0".parseSemVer()
             val commitDate = LocalDate.of(2019, 8, 27)
             return when {
                 ver.semver > minRelease -> true
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 d4fa7e299..20022d1a6 100644
--- a/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt
+++ b/src/main/kotlin/org/rust/cargo/runconfig/buildtool/CargoBuildManager.kt
@@ -43,6 +43,7 @@ import org.rust.cargo.runconfig.command.CargoCommandConfiguration
 import org.rust.cargo.runconfig.wasmpack.WasmPackBuildTaskProvider
 import org.rust.cargo.toolchain.CargoCommandLine
 import org.rust.cargo.util.CargoArgsParser.Companion.parseArgs
+import org.rust.cargo.util.parseSemVer
 import org.rust.ide.experiments.RsExperiments
 import org.rust.ide.notifications.RsNotifications
 import org.rust.openapiext.isFeatureEnabled
@@ -57,7 +58,7 @@ object CargoBuildManager {
     private val CANCELED_BUILD_RESULT: Future<CargoBuildResult> =
         FutureResult(CargoBuildResult(succeeded = false, canceled = true, started = 0))
 
-    private val MIN_RUSTC_VERSION: SemVer = SemVer.parseFromText("1.48.0")!!
+    private val MIN_RUSTC_VERSION: SemVer = "1.48.0".parseSemVer()
 
     val RsCommandConfiguration.isBuildToolWindowEnabled: Boolean
         get() {
diff --git a/src/main/kotlin/org/rust/cargo/toolchain/RsToolchainBase.kt b/src/main/kotlin/org/rust/cargo/toolchain/RsToolchainBase.kt
index 724eee681..dd7c4e120 100644
--- a/src/main/kotlin/org/rust/cargo/toolchain/RsToolchainBase.kt
+++ b/src/main/kotlin/org/rust/cargo/toolchain/RsToolchainBase.kt
@@ -12,11 +12,11 @@ import com.intellij.execution.wsl.WslPath
 import com.intellij.openapi.util.SystemInfo
 import com.intellij.util.io.exists
 import com.intellij.util.net.HttpConfigurable
-import com.intellij.util.text.SemVer
 import org.rust.cargo.CargoConstants
 import org.rust.cargo.toolchain.flavors.RsToolchainFlavor
 import org.rust.cargo.toolchain.tools.Cargo
 import org.rust.cargo.toolchain.wsl.getHomePathCandidates
+import org.rust.cargo.util.parseSemVer
 import org.rust.openapiext.GeneralCommandLine
 import org.rust.openapiext.withWorkDirectory
 import java.io.File
@@ -119,7 +119,7 @@ abstract class RsToolchainBase(val location: Path) {
     }
 
     companion object {
-        val MIN_SUPPORTED_TOOLCHAIN = SemVer.parseFromText("1.41.0")!!
+        val MIN_SUPPORTED_TOOLCHAIN = "1.41.0".parseSemVer()
 
         /** Environment variable to unlock unstable features of rustc and cargo.
          *  It doesn't change real toolchain.
diff --git a/src/main/kotlin/org/rust/cargo/toolchain/tools/Cargo.kt b/src/main/kotlin/org/rust/cargo/toolchain/tools/Cargo.kt
index 77b1ec465..88e2dd37b 100644
--- a/src/main/kotlin/org/rust/cargo/toolchain/tools/Cargo.kt
+++ b/src/main/kotlin/org/rust/cargo/toolchain/tools/Cargo.kt
@@ -50,6 +50,7 @@ import org.rust.cargo.toolchain.tools.ProjectDescriptionStatus.BUILD_SCRIPT_EVAL
 import org.rust.cargo.toolchain.tools.ProjectDescriptionStatus.OK
 import org.rust.cargo.toolchain.tools.Rustup.Companion.checkNeedInstallClippy
 import org.rust.cargo.toolchain.wsl.RsWslToolchain
+import org.rust.cargo.util.parseSemVer
 import org.rust.ide.actions.InstallBinaryCrateAction
 import org.rust.ide.experiments.RsExperiments
 import org.rust.ide.notifications.showBalloon
@@ -417,7 +418,7 @@ class Cargo(toolchain: RsToolchainBase, useWrapper: Boolean = false)
 
     fun checkNeedInstallCargoGenerate(): Boolean {
         val crateName = "cargo-generate"
-        val minVersion = SemVer("v0.9.0", 0, 9, 0)
+        val minVersion = "0.9.0".parseSemVer()
         return checkBinaryCrateIsNotInstalled(crateName, minVersion)
     }
 
@@ -503,7 +504,7 @@ class Cargo(toolchain: RsToolchainBase, useWrapper: Boolean = false)
 
         fun checkNeedInstallGrcov(project: Project): Boolean {
             val crateName = "grcov"
-            val minVersion = SemVer("v0.4.3", 0, 4, 3)
+            val minVersion = "0.7.0".parseSemVer()
             return checkNeedInstallBinaryCrate(
                 project,
                 crateName,
@@ -515,7 +516,7 @@ class Cargo(toolchain: RsToolchainBase, useWrapper: Boolean = false)
 
         fun checkNeedInstallCargoExpand(project: Project): Boolean {
             val crateName = "cargo-expand"
-            val minVersion = SemVer("v1.0.0", 1, 0, 0)
+            val minVersion = "1.0.0".parseSemVer()
             return checkNeedInstallBinaryCrate(
                 project,
                 crateName,
@@ -527,7 +528,7 @@ class Cargo(toolchain: RsToolchainBase, useWrapper: Boolean = false)
 
         fun checkNeedInstallEvcxr(project: Project): Boolean {
             val crateName = "evcxr_repl"
-            val minVersion = SemVer("v0.10.0", 0, 10, 0)
+            val minVersion = "0.10.0".parseSemVer()
             return checkNeedInstallBinaryCrate(
                 project,
                 crateName,
@@ -539,7 +540,7 @@ class Cargo(toolchain: RsToolchainBase, useWrapper: Boolean = false)
 
         fun checkNeedInstallWasmPack(project: Project): Boolean {
             val crateName = "wasm-pack"
-            val minVersion = SemVer("v0.9.1", 0, 9, 1)
+            val minVersion = "0.9.1".parseSemVer()
             return checkNeedInstallBinaryCrate(
                 project,
                 crateName,
diff --git a/src/main/kotlin/org/rust/cargo/util/ToolchainUtil.kt b/src/main/kotlin/org/rust/cargo/util/ToolchainUtil.kt
index b1aec79b4..da4133142 100644
--- a/src/main/kotlin/org/rust/cargo/util/ToolchainUtil.kt
+++ b/src/main/kotlin/org/rust/cargo/util/ToolchainUtil.kt
@@ -6,9 +6,12 @@
 package org.rust.cargo.util
 
 import com.intellij.openapi.util.SystemInfo
+import com.intellij.util.text.SemVer
 import org.rust.stdext.isExecutable
 import java.nio.file.Path
 
+fun String.parseSemVer(): SemVer = checkNotNull(SemVer.parseFromText(this)) { "Invalid version value: $this" }
+
 fun Path.hasExecutable(toolName: String): Boolean = pathToExecutable(toolName).isExecutable()
 
 fun Path.pathToExecutable(toolName: String): Path {
diff --git a/src/main/kotlin/org/rust/lang/core/CompilerFeature.kt b/src/main/kotlin/org/rust/lang/core/CompilerFeature.kt
index 9e18310b0..e36efbf8e 100644
--- a/src/main/kotlin/org/rust/lang/core/CompilerFeature.kt
+++ b/src/main/kotlin/org/rust/lang/core/CompilerFeature.kt
@@ -12,6 +12,7 @@ import com.intellij.psi.PsiElement
 import com.intellij.util.text.SemVer
 import org.rust.cargo.project.workspace.PackageOrigin
 import org.rust.cargo.toolchain.RustChannel
+import org.rust.cargo.util.parseSemVer
 import org.rust.ide.annotator.RsAnnotationHolder
 import org.rust.ide.annotator.fixes.AddFeatureAttributeFix
 import org.rust.lang.core.FeatureAvailability.*
@@ -34,7 +35,7 @@ class CompilerFeature(
         state: FeatureState,
         since: String,
         cache: Boolean = true
-    ) : this(name, state, SemVer.parseFromText(since)!!, cache)
+    ) : this(name, state, since.parseSemVer(), cache)
 
     init {
         if (cache) {
diff --git a/src/test/kotlin/org/rust/RsTestBase.kt b/src/test/kotlin/org/rust/RsTestBase.kt
index b5c529d1e..90a036f1c 100644
--- a/src/test/kotlin/org/rust/RsTestBase.kt
+++ b/src/test/kotlin/org/rust/RsTestBase.kt
@@ -33,6 +33,7 @@ import org.rust.cargo.project.workspace.CargoWorkspace
 import org.rust.cargo.project.workspace.PackageFeature
 import org.rust.cargo.toolchain.RustChannel
 import org.rust.cargo.toolchain.impl.RustcVersion
+import org.rust.cargo.util.parseSemVer
 import org.rust.lang.core.macros.macroExpansionManager
 import org.rust.openapiext.Testmark
 import org.rust.openapiext.document
@@ -179,7 +180,7 @@ abstract class RsTestBase : BasePlatformTestCase(), RsTestCase {
         val result = versionRe.matchEntire(version) ?: error("$version should match `${versionRe.pattern}` pattern")
 
         val versionText = result.groups[1]?.value ?: error("")
-        val semVer = SemVer.parseFromText(versionText) ?: error("")
+        val semVer = versionText.parseSemVer()
 
         val releaseSuffix = result.groups[2]?.value.orEmpty()
         val channel = when {
diff --git a/src/test/kotlin/org/rust/RustcVersion.kt b/src/test/kotlin/org/rust/RustcVersion.kt
index 1c62fa7a9..b8371fbfc 100644
--- a/src/test/kotlin/org/rust/RustcVersion.kt
+++ b/src/test/kotlin/org/rust/RustcVersion.kt
@@ -9,6 +9,7 @@ import com.intellij.findAnnotationInstance
 import com.intellij.util.text.SemVer
 import junit.framework.TestCase
 import org.rust.cargo.project.model.CargoProject
+import org.rust.cargo.util.parseSemVer
 import org.rust.stdext.RsResult
 
 /**
@@ -35,7 +36,7 @@ annotation class MockRustcVersion(val rustcVersion: String)
 @Retention(AnnotationRetention.RUNTIME)
 annotation class MinRustcVersion(val version: String)
 
-val MinRustcVersion.semver: SemVer get() = SemVer.parseFromText(version) ?: error("Invalid version value: $version")
+val MinRustcVersion.semver: SemVer get() = version.parseSemVer()
 
 /**
  * Specify maximum rustc version to launch test.
@@ -44,7 +45,7 @@ val MinRustcVersion.semver: SemVer get() = SemVer.parseFromText(version) ?: erro
 @Retention(AnnotationRetention.RUNTIME)
 annotation class MaxRustcVersion(val version: String)
 
-val MaxRustcVersion.semver: SemVer get() = SemVer.parseFromText(version) ?: error("Invalid version value: $version")
+val MaxRustcVersion.semver: SemVer get() = version.parseSemVer()
 
 fun TestCase.checkRustcVersionRequirements(rustcVersionSupplier: () -> RsResult<SemVer, String?>): String? {
     val minRustVersion = findAnnotationInstance<MinRustcVersion>()
diff --git a/src/test/kotlin/org/rust/cargo/runconfig/CargoTestRunStateTest.kt b/src/test/kotlin/org/rust/cargo/runconfig/CargoTestRunStateTest.kt
index 29f7a82f3..4213b31f3 100644
--- a/src/test/kotlin/org/rust/cargo/runconfig/CargoTestRunStateTest.kt
+++ b/src/test/kotlin/org/rust/cargo/runconfig/CargoTestRunStateTest.kt
@@ -6,7 +6,6 @@
 package org.rust.cargo.runconfig
 
 import com.intellij.util.execution.ParametersListUtil
-import com.intellij.util.text.SemVer
 import org.junit.Assert.*
 import org.junit.Test
 import org.junit.runner.RunWith
@@ -14,6 +13,7 @@ import org.junit.runners.Parameterized
 import org.rust.cargo.toolchain.CargoCommandLine
 import org.rust.cargo.toolchain.RustChannel
 import org.rust.cargo.toolchain.impl.RustcVersion
+import org.rust.cargo.util.parseSemVer
 import java.nio.file.Path
 import java.nio.file.Paths
 import java.time.LocalDate
@@ -31,7 +31,7 @@ class CargoTestRunStatePatchArgsTest(
         CargoTestRunState.patchArgs(
             CargoCommandLine("run", wd, ParametersListUtil.parse(input)),
             RustcVersion(
-                SemVer.parseFromText("1.38.0")!!,
+                "1.38.0".parseSemVer(),
                 "x86_64-unknown-linux-gnu",
                 RustChannel.STABLE
             )
@@ -44,7 +44,7 @@ class CargoTestRunStatePatchArgsTest(
         CargoTestRunState.patchArgs(
             CargoCommandLine("run", wd, ParametersListUtil.parse(input)),
             RustcVersion(
-                SemVer.parseFromText("1.39.0")!!,
+                "1.39.0".parseSemVer(),
                 "x86_64-unknown-linux-gnu",
                 RustChannel.STABLE
             )
@@ -74,7 +74,7 @@ class CargoTestRunStatePatchArgsShowOutputEnableTest {
     private fun patchArgs(version: String, channel: RustChannel, date: LocalDate) = CargoTestRunState.patchArgs(
         CargoCommandLine("run", Paths.get("/my-crate"), ParametersListUtil.parse("")),
         RustcVersion(
-            SemVer.parseFromText(version)!!,
+            version.parseSemVer(),
             "x86_64-unknown-linux-gnu",
             channel,
             null,
diff --git a/src/test/kotlin/org/rust/cargo/toolchain/RustcVersionParsingTest.kt b/src/test/kotlin/org/rust/cargo/toolchain/RustcVersionParsingTest.kt
index ee27b8133..bba3ab0ee 100644
--- a/src/test/kotlin/org/rust/cargo/toolchain/RustcVersionParsingTest.kt
+++ b/src/test/kotlin/org/rust/cargo/toolchain/RustcVersionParsingTest.kt
@@ -5,7 +5,6 @@
 
 package org.rust.cargo.toolchain
 
-import com.intellij.util.text.SemVer.parseFromText
 import org.junit.Assert.assertEquals
 import org.junit.Test
 import org.junit.runner.RunWith
@@ -13,6 +12,7 @@ import org.junit.runners.Parameterized
 import org.rust.cargo.toolchain.RustChannel.*
 import org.rust.cargo.toolchain.impl.RustcVersion
 import org.rust.cargo.toolchain.impl.parseRustcVersion
+import org.rust.cargo.util.parseSemVer
 import java.time.LocalDate.parse as parseDate
 
 @RunWith(Parameterized::class)
@@ -39,7 +39,7 @@ class RustcVersionParsingTest(
                 release: 1.37.0
                 LLVM version: 8.0
             """, RustcVersion(
-                parseFromText("1.37.0")!!,
+                "1.37.0".parseSemVer(),
                 "x86_64-apple-darwin",
                 STABLE,
                 "eae3437dfe991621e8afdc82734f4a172d7ddf9b",
@@ -54,7 +54,7 @@ class RustcVersionParsingTest(
                 release: 1.39.0-nightly
                 LLVM version: 9.0
             """, RustcVersion(
-                parseFromText("1.39.0-nightly")!!,
+                "1.39.0-nightly".parseSemVer(),
                 "x86_64-unknown-linux-gnu",
                 NIGHTLY,
                 "9af17757be1cc3f672928ecf06c40a662c5ec26d",
@@ -69,7 +69,7 @@ class RustcVersionParsingTest(
                 release: 1.38.0-beta.2
                 LLVM version: 9.0
             """, RustcVersion(
-                parseFromText("1.38.0-beta.2")!!,
+                "1.38.0-beta.2".parseSemVer(),
                 "x86_64-apple-darwin",
                 BETA,
                 "641586c1a54f1b1740f8dd796d7501e34c044da2",
@@ -84,7 +84,7 @@ class RustcVersionParsingTest(
                 release: 1.37.0
                 LLVM version: 8.0
             """, RustcVersion(
-                parseFromText("1.37.0")!!,
+                "1.37.0".parseSemVer(),
                 "x86_64-unknown-linux-gnu",
                 STABLE,
                 null,
diff --git a/src/test/kotlin/org/rust/lang/core/macros/decl/RsMacroExpansionTest.kt b/src/test/kotlin/org/rust/lang/core/macros/decl/RsMacroExpansionTest.kt
index dbadfd903..e0203b372 100644
--- a/src/test/kotlin/org/rust/lang/core/macros/decl/RsMacroExpansionTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/macros/decl/RsMacroExpansionTest.kt
@@ -6,11 +6,11 @@
 package org.rust.lang.core.macros.decl
 
 import com.intellij.psi.tree.TokenSet
-import com.intellij.util.text.SemVer
 import org.rust.*
 import org.rust.cargo.project.model.cargoProjects
 import org.rust.cargo.project.workspace.CargoWorkspace.Edition.EDITION_2018
 import org.rust.cargo.project.workspace.CargoWorkspace.Edition.EDITION_2021
+import org.rust.cargo.util.parseSemVer
 import org.rust.lang.core.macros.RsMacroExpansionTestBase
 import org.rust.lang.core.psi.RS_KEYWORDS
 import org.rust.lang.core.psi.RsElementTypes.CRATE
@@ -841,7 +841,7 @@ class RsMacroExpansionTest : RsMacroExpansionTestBase() {
     fun `test standard "vec!"`() {
         val rustcVersion = project.cargoProjects.singleProject().rustcInfo?.version?.semver
         // BACKCOMPAT: Rust 1.50
-        val expansion = if (rustcVersion != null && rustcVersion < SemVer.parseFromText("1.51.0")!!) {
+        val expansion = if (rustcVersion != null && rustcVersion < "1.51.0".parseSemVer()) {
             // language=Rust
             "<[_]>::into_vec(box [1, 2, 3])"
         } else {
diff --git a/src/test/kotlin/org/rust/lang/core/stubs/RsLazyBlockStubCreationTestBase.kt b/src/test/kotlin/org/rust/lang/core/stubs/RsLazyBlockStubCreationTestBase.kt
index 710c71541..c0300df72 100644
--- a/src/test/kotlin/org/rust/lang/core/stubs/RsLazyBlockStubCreationTestBase.kt
+++ b/src/test/kotlin/org/rust/lang/core/stubs/RsLazyBlockStubCreationTestBase.kt
@@ -18,10 +18,10 @@ import com.intellij.psi.impl.source.tree.TreeUtil
 import com.intellij.psi.stubs.PsiFileStub
 import com.intellij.psi.stubs.StubTree
 import com.intellij.util.LocalTimeCounter
-import com.intellij.util.text.SemVer
 import junit.framework.TestCase
 import org.rust.RsTestBase
 import org.rust.RustProjectDescriptorBase
+import org.rust.cargo.util.parseSemVer
 import org.rust.lang.RsFileType
 import org.rust.lang.core.psi.*
 import org.rust.lang.core.psi.ext.RsAttrProcMacroOwner
@@ -180,6 +180,6 @@ abstract class RsLazyBlockStubCreationTestBase : RsTestBase() {
 
     companion object {
         // BACKCOMPAT: Rust 1.42
-        private val RUST_1_43 = SemVer.parseFromText("1.43.0")!!
+        private val RUST_1_43 = "1.43.0".parseSemVer()
     }
 }
diff --git a/src/test/kotlin/org/rustSlowTests/lang/resolve/CustomTargetCfgResolveTest.kt b/src/test/kotlin/org/rustSlowTests/lang/resolve/CustomTargetCfgResolveTest.kt
index 72e07952b..e51361c59 100644
--- a/src/test/kotlin/org/rustSlowTests/lang/resolve/CustomTargetCfgResolveTest.kt
+++ b/src/test/kotlin/org/rustSlowTests/lang/resolve/CustomTargetCfgResolveTest.kt
@@ -5,10 +5,10 @@
 
 package org.rustSlowTests.lang.resolve
 
-import com.intellij.util.text.SemVer
 import org.rust.MinRustcVersion
 import org.rust.cargo.RsWithToolchainTestBase
 import org.rust.cargo.toolchain.tools.rustc
+import org.rust.cargo.util.parseSemVer
 import org.rust.lang.core.psi.RsPath
 
 class CustomTargetCfgResolveTest : RsWithToolchainTestBase() {
@@ -118,7 +118,7 @@ class CustomTargetCfgResolveTest : RsWithToolchainTestBase() {
     // Checks that our integration doesn't fail for Rust below 1.52
     fun `test custom compiler target with rust below 1_52`() {
         val rustcVersion = rustupFixture.toolchain!!.rustc().queryVersion() ?: return
-        if (rustcVersion.semver > SemVer.parseFromText("1.51.0")) return
+        if (rustcVersion.semver > "1.51.0".parseSemVer()) return
         buildProject {
             toml("Cargo.toml", """
                 [package]