From b03b5dc9ee0f7c9902dd7a439826ef1dff502c43 Mon Sep 17 00:00:00 2001 From: tignear Date: Sat, 31 Oct 2026 19:31:30 +0900 Subject: [PATCH] chore(lint): forbid RefCell and Cell State is owned and passed explicitly. `clippy.toml` now rejects `std::cell::RefCell` and `std::cell::Cell`, so code takes `&mut`, returns results, or keys caches by all their inputs instead of mutating shared state behind shared references. No crate outside tests uses them any more. Two exceptions are allowed with a reason: celox-vpi, whose callbacks re-enter the layer from C while it holds the simulation, and the analyzer's unit tests, whose thread-local work counters exist only in test builds (non-test builds still enforce the ban). Change-Id: Ic824647aa2413e8752452d50b5b7962110736993 --- clippy.toml | 2 ++ crates/celox-sv-analyzer/src/lib.rs | 3 ++- crates/celox-vpi/src/lib.rs | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clippy.toml b/clippy.toml index 7d2bbf4515e..2d8b9dd506f 100644 --- a/clippy.toml +++ b/clippy.toml @@ -13,4 +13,6 @@ disallowed-methods = [ disallowed-types = [ { path = "std::collections::HashMap", reason = "compiler data is trusted; use fxhash::FxHashMap (or the crate HashMap alias) to avoid RandomState overhead" }, { path = "std::collections::HashSet", reason = "compiler data is trusted; use fxhash::FxHashSet (or the crate HashSet alias) to avoid RandomState overhead" }, + { path = "std::cell::RefCell", reason = "state is owned and passed explicitly: take &mut, return results, or key caches by all their inputs instead of mutating shared state behind shared references" }, + { path = "std::cell::Cell", reason = "state is owned and passed explicitly: take &mut, return results, or key caches by all their inputs instead of mutating shared state behind shared references" }, ] diff --git a/crates/celox-sv-analyzer/src/lib.rs b/crates/celox-sv-analyzer/src/lib.rs index 544bbcd5c38..7ab3c3ceed6 100644 --- a/crates/celox-sv-analyzer/src/lib.rs +++ b/crates/celox-sv-analyzer/src/lib.rs @@ -2,7 +2,8 @@ test, allow( clippy::disallowed_macros, - reason = "thread-local counters exist only in unit tests; non-test library builds enforce the ban" + clippy::disallowed_types, + reason = "thread-local counters and their cells exist only in unit tests; non-test library builds enforce the bans" ) )] //! SystemVerilog analyzer for Celox. diff --git a/crates/celox-vpi/src/lib.rs b/crates/celox-vpi/src/lib.rs index 412fadba113..46861a550b6 100644 --- a/crates/celox-vpi/src/lib.rs +++ b/crates/celox-vpi/src/lib.rs @@ -9,6 +9,10 @@ not(any(target_arch = "x86_64", target_arch = "aarch64")), allow(dead_code) )] +#![allow( + clippy::disallowed_types, + reason = "VPI callbacks re-enter the layer from C while it holds the simulation, so its state is shared behind the C boundary" +)] #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] compile_error!("celox-vpi currently supports only x86-64 and AArch64");