From 56e18ba6d66df400639efb3758dddf6c39eef2b6 Mon Sep 17 00:00:00 2001 From: vumichien Date: Mon, 9 Jun 2025 15:35:08 +0900 Subject: [PATCH] chore: update Rust version to 1.86 and remove unused `as_any` methods from various implementations --- Cargo.toml | 1 + src/execution/db_tracking_setup.rs | 4 +--- src/ops/factory_bases.rs | 4 +--- src/ops/storages/kuzu.rs | 4 +--- src/ops/storages/neo4j.rs | 4 +--- src/ops/storages/postgres.rs | 4 +--- src/ops/storages/qdrant.rs | 4 +--- src/setup/components.rs | 8 -------- src/setup/db_metadata.rs | 4 +--- src/setup/states.rs | 16 ++-------------- 10 files changed, 10 insertions(+), 43 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6841f630b..2cc6b8a82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ name = "cocoindex" # Will be overridden for specific release versions. version = "999.0.0" edition = "2024" +rust-version = "1.86" [profile.release] codegen-units = 1 diff --git a/src/execution/db_tracking_setup.rs b/src/execution/db_tracking_setup.rs index 1aaa0a0e7..1a0446448 100644 --- a/src/execution/db_tracking_setup.rs +++ b/src/execution/db_tracking_setup.rs @@ -155,9 +155,7 @@ impl ResourceSetupStatus for TrackingTableSetupStatus { } } - fn as_any(&self) -> &dyn Any { - self as &dyn Any - } + } impl TrackingTableSetupStatus { diff --git a/src/ops/factory_bases.rs b/src/ops/factory_bases.rs index c4f523ae4..e4d33970c 100644 --- a/src/ops/factory_bases.rs +++ b/src/ops/factory_bases.rs @@ -504,9 +504,7 @@ impl ExportTargetFactory for T { .map(|item| -> anyhow::Result<_> { Ok(TypedResourceSetupChangeItem { key: serde_json::from_value(item.key.clone())?, - setup_status: item - .setup_status - .as_any() + setup_status: (item.setup_status as &dyn Any) .downcast_ref::() .ok_or_else(invariance_violation)?, }) diff --git a/src/ops/storages/kuzu.rs b/src/ops/storages/kuzu.rs index 7fcda26dc..fbe9ff3b0 100644 --- a/src/ops/storages/kuzu.rs +++ b/src/ops/storages/kuzu.rs @@ -195,9 +195,7 @@ impl setup::ResourceSetupStatus for GraphElementDataSetupStatus { self.actions.change_type(false) } - fn as_any(&self) -> &dyn Any { - self - } + } fn append_drop_table( diff --git a/src/ops/storages/neo4j.rs b/src/ops/storages/neo4j.rs index 0d08a554a..a80f053ee 100644 --- a/src/ops/storages/neo4j.rs +++ b/src/ops/storages/neo4j.rs @@ -854,9 +854,7 @@ impl ResourceSetupStatus for GraphElementDataSetupStatus { self.change_type } - fn as_any(&self) -> &dyn Any { - self - } + } async fn clear_graph_element_data( diff --git a/src/ops/storages/postgres.rs b/src/ops/storages/postgres.rs index 18d468f96..d627ccecb 100644 --- a/src/ops/storages/postgres.rs +++ b/src/ops/storages/postgres.rs @@ -526,9 +526,7 @@ impl setup::ResourceSetupStatus for SetupStatus { self.actions.table_action.change_type(has_other_update) } - fn as_any(&self) -> &dyn Any { - self - } + } impl SetupStatus { diff --git a/src/ops/storages/qdrant.rs b/src/ops/storages/qdrant.rs index c8155db1f..066c9c598 100644 --- a/src/ops/storages/qdrant.rs +++ b/src/ops/storages/qdrant.rs @@ -142,9 +142,7 @@ impl setup::ResourceSetupStatus for SetupStatus { } } - fn as_any(&self) -> &dyn Any { - self - } + } impl SetupStatus { diff --git a/src/setup/components.rs b/src/setup/components.rs index 738bc298a..b0cf74b89 100644 --- a/src/setup/components.rs +++ b/src/setup/components.rs @@ -143,10 +143,6 @@ impl ResourceSetupStatus for SetupStatus { SetupChangeType::Update } } - - fn as_any(&self) -> &dyn Any { - self - } } pub async fn apply_component_changes( @@ -191,8 +187,4 @@ impl ResourceSetupStatus for (A, (a, _) => a, } } - - fn as_any(&self) -> &dyn Any { - self - } } diff --git a/src/setup/db_metadata.rs b/src/setup/db_metadata.rs index 64f67c8db..01b93029d 100644 --- a/src/setup/db_metadata.rs +++ b/src/setup/db_metadata.rs @@ -349,9 +349,7 @@ impl ResourceSetupStatus for MetadataTableSetup { } } - fn as_any(&self) -> &dyn Any { - self as &dyn Any - } + } impl MetadataTableSetup { diff --git a/src/setup/states.rs b/src/setup/states.rs index 9821930c7..d1dda2166 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -15,6 +15,7 @@ use crate::prelude::*; use indenter::indented; use owo_colors::{AnsiColors, OwoColorize}; +use std::any::Any; use std::fmt::Debug; use std::fmt::{Display, Write}; use std::hash::Hash; @@ -218,15 +219,10 @@ pub enum SetupChangeType { Invalid, } -pub trait ResourceSetupStatus: Send + Sync + Debug + 'static { +pub trait ResourceSetupStatus: Send + Sync + Debug + Any + 'static { fn describe_changes(&self) -> Vec; fn change_type(&self) -> SetupChangeType; - - // Workaround as Rust doesn't support dyn upcasting before 1.86. - // (https://github.com/rust-lang/rust/issues/65991) - // Can be replaced by a `Any` bound when we require Rust 1.86 or newer. - fn as_any(&self) -> &dyn Any; } impl ResourceSetupStatus for Box { @@ -237,10 +233,6 @@ impl ResourceSetupStatus for Box { fn change_type(&self) -> SetupChangeType { self.as_ref().change_type() } - - fn as_any(&self) -> &dyn Any { - self as &dyn Any - } } impl ResourceSetupStatus for std::convert::Infallible { @@ -251,10 +243,6 @@ impl ResourceSetupStatus for std::convert::Infallible { fn change_type(&self) -> SetupChangeType { unreachable!() } - - fn as_any(&self) -> &dyn Any { - self as &dyn Any - } } #[derive(Debug)]