From fdc7751457aa899344f8436ac67cffcda65a3f6d Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:52:55 +0100 Subject: [PATCH] toolchains: Do not use as_json representation for PartialEq (#21682) Closes #21679 Release Notes: - N/A --- crates/language/src/toolchain.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/language/src/toolchain.rs b/crates/language/src/toolchain.rs index 13703d81a7..5b48157f0f 100644 --- a/crates/language/src/toolchain.rs +++ b/crates/language/src/toolchain.rs @@ -14,7 +14,7 @@ use settings::WorktreeId; use crate::LanguageName; /// Represents a single toolchain. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] pub struct Toolchain { /// User-facing label pub name: SharedString, @@ -24,6 +24,18 @@ pub struct Toolchain { pub as_json: serde_json::Value, } +impl PartialEq for Toolchain { + fn eq(&self, other: &Self) -> bool { + // Do not use as_json for comparisons; it shouldn't impact equality, as it's not user-surfaced. + // Thus, there could be multiple entries that look the same in the UI. + (&self.name, &self.path, &self.language_name).eq(&( + &other.name, + &other.path, + &other.language_name, + )) + } +} + #[async_trait] pub trait ToolchainLister: Send + Sync { async fn list(