chore(lint): inherit workspace lints in draft and logging crates

clash-verge-draft and clash-verge-logging did not inherit
[workspace.lints], so cargo's missing_lints_inheritance warned and the
strict clippy set never applied to them. Inheriting the lints surfaced
six errors, now fixed:

- draft: drop the data lock before cloning the snapshot and before
  returning in with_data_modify (significant_drop_tightening)
- draft: require T: Send + Sync on acquire_data_modify_permit so its
  future is Send (future_not_send)
- draft bench: scope an allow for the runtime-init panic
- logging: make Logger::new const (missing_const_for_fn)
- logging: return the builder directly from generate_file_log_writer,
  which never failed (unnecessary_wraps)

The three unused-dependency warnings that remain under
--all-features are cfg artifacts, not dead deps: tauri-build is only
called when the clippy feature is off, tauri-plugin-devtools is
compiled out when tokio-trace is enabled alongside tauri-dev, and
clash-verge-logging in clash-verge-signal is only referenced by the
Linux-only body of that crate.
This commit is contained in:
Tunglies
2026-11-18 09:45:36 +08:00
parent 16667137a7
commit 7d8fec7314
5 changed files with 19 additions and 8 deletions
+3
View File
@@ -15,3 +15,6 @@ tokio = { workspace = true }
[dev-dependencies]
criterion = { workspace = true }
[lints]
workspace = true
@@ -19,6 +19,7 @@ fn make_draft() -> Draft<IVerge> {
}
pub fn bench_draft(c: &mut Criterion) {
#[allow(clippy::panic, reason = "bench setup cannot proceed without a runtime")]
let rt = Runtime::new().unwrap_or_else(|e| panic!("Tokio runtime init failed: {e}"));
let mut group = c.benchmark_group("draft");
+6 -1
View File
@@ -102,6 +102,7 @@ impl<T: Clone> Draft<T> {
let (local, original_arc) = {
let guard = self.inner.data.lock();
let arc = Arc::clone(&guard.0);
drop(guard);
((**arc).clone(), arc)
};
let (new_local, res) = f(local).await?;
@@ -112,6 +113,7 @@ impl<T: Clone> Draft<T> {
));
}
guard.0 = Arc::new(Box::new(new_local));
drop(guard);
Ok(res)
}
@@ -125,7 +127,10 @@ impl<T: Clone> Draft<T> {
}
#[inline]
async fn acquire_data_modify_permit(&self) -> DataModifyPermit<'_> {
async fn acquire_data_modify_permit(&self) -> DataModifyPermit<'_>
where
T: Send + Sync,
{
for _ in 0..DATA_MODIFY_FAST_RETRY_YIELDS {
if let Some(permit) = self.try_acquire_data_modify_permit() {
return permit;
+3
View File
@@ -15,3 +15,6 @@ default = []
tokio-trace = ["tracing-estuary/tokio-trace"]
chrome-trace = ["tracing-estuary/chrome-trace"]
color = ["tracing-estuary/color"]
[lints]
workspace = true
+6 -7
View File
@@ -160,7 +160,7 @@ pub struct Logger {
static LOGGER: OnceLock<Logger> = OnceLock::new();
impl Logger {
fn new() -> Self {
const fn new() -> Self {
Self {
pipeline: OnceLock::new(),
sidecar_file_writer: RwLock::new(None),
@@ -185,7 +185,7 @@ impl Logger {
self.store_config(cfg);
let pipeline = tracing_estuary::PipelineBuilder::new()
.default_level(log_level)
.file_writer(self.generate_file_log_writer()?)
.file_writer(self.generate_file_log_writer())
.init()?;
self.pipeline.set(pipeline).ok();
Ok(())
@@ -225,11 +225,11 @@ impl Logger {
self.log_max_count.store(cfg.max_count, Ordering::SeqCst);
}
fn generate_file_log_writer(&self) -> Result<FileLogWriterBuilder> {
fn generate_file_log_writer(&self) -> FileLogWriterBuilder {
let log_dir = self.log_dir.get().cloned().unwrap_or_default();
let log_max_size = self.log_max_size.load(Ordering::SeqCst);
let log_max_count = self.log_max_count.load(Ordering::SeqCst);
let flwb = FileLogWriter::builder(FileSpec::default().directory(log_dir).basename(""))
FileLogWriter::builder(FileSpec::default().directory(log_dir).basename(""))
.format(tracing_estuary::file_format_with_level)
.write_mode(flexi_logger::WriteMode::BufferAndFlushWith(
WRITE_BUFFER_CAPACITY,
@@ -239,8 +239,7 @@ impl Logger {
Criterion::Size(log_max_size * 1024),
ROTATE_NAMING,
Cleanup::KeepLogFiles(log_max_count),
);
Ok(flwb)
)
}
/// Ensures the sidecar writer exists and points at `builder`'s config:
@@ -311,7 +310,7 @@ impl Logger {
self.log_max_size.store(log_max_size, Ordering::SeqCst);
self.log_max_count.store(log_max_count, Ordering::SeqCst);
if let Some(pipeline) = self.pipeline.get() {
let log_file_writer = self.generate_file_log_writer()?;
let log_file_writer = self.generate_file_log_writer();
if let Some(sink) = pipeline.sink.as_ref() {
sink.reset(log_file_writer)
.map_err(|error| anyhow::anyhow!("failed to reset log writer: {error}"))?;