From 2a93a241674a777cb8d898317ab805339580c1cb Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 28 May 2026 09:59:42 +0300 Subject: [PATCH] rustfmt: don't try to format autogened _lex Lewis: May this revision serve well! --- .tangled/workflows/fmt.yml | 2 ++ bobbin/crates/bobbin/src/main.rs | 15 ++++---- bobbin/crates/edge-index/src/lib.rs | 34 ++++++++++++++----- .../crates/edge-index/tests/bucket_scaling.rs | 18 ++++------ bobbin/crates/record-lru/src/lib.rs | 5 +-- bobbin/crates/xrpc/tests/aggregation.rs | 6 +++- bobbin/default.nix | 2 -- 7 files changed, 49 insertions(+), 33 deletions(-) diff --git a/.tangled/workflows/fmt.yml b/.tangled/workflows/fmt.yml index 7e892551..704d4eaa 100644 --- a/.tangled/workflows/fmt.yml +++ b/.tangled/workflows/fmt.yml @@ -7,4 +7,6 @@ engine: nixery steps: - name: "Check formatting" command: | + mkdir -p bobbin/crates/types/src/_lex + [ -f bobbin/crates/types/src/_lex/lib.rs ] || : > bobbin/crates/types/src/_lex/lib.rs nix run .#fmt -- --ci diff --git a/bobbin/crates/bobbin/src/main.rs b/bobbin/crates/bobbin/src/main.rs index 01e1db07..49ace415 100644 --- a/bobbin/crates/bobbin/src/main.rs +++ b/bobbin/crates/bobbin/src/main.rs @@ -247,13 +247,14 @@ async fn run(cfg: BobbinConfig) -> anyhow::Result<()> { ) }); - let debug_bind: Option = if cfg.server.debug_bind.is_empty() { - None - } else { - Some(cfg.server.debug_bind.parse().with_context(|| { - format!("invalid server.debug_bind `{}`", cfg.server.debug_bind) - })?) - }; + let debug_bind: Option = + if cfg.server.debug_bind.is_empty() { + None + } else { + Some(cfg.server.debug_bind.parse().with_context(|| { + format!("invalid server.debug_bind `{}`", cfg.server.debug_bind) + })?) + }; let mem_probe = debug_bind.is_some().then(|| mem::MemProbe { edges: edges.clone(), search: search.clone(), diff --git a/bobbin/crates/edge-index/src/lib.rs b/bobbin/crates/edge-index/src/lib.rs index aea493d6..d26a35b8 100644 --- a/bobbin/crates/edge-index/src/lib.rs +++ b/bobbin/crates/edge-index/src/lib.rs @@ -251,7 +251,22 @@ pub struct EdgeMemReport { } const BUCKET_CLASS_BOUNDS: [u64; 16] = [ - 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 8192, 32768, 131072, u64::MAX, + 1, + 2, + 4, + 8, + 16, + 32, + 64, + 128, + 256, + 512, + 1024, + 2048, + 8192, + 32768, + 131072, + u64::MAX, ]; const BUCKET_CLASS_COUNT: usize = BUCKET_CLASS_BOUNDS.len(); @@ -264,7 +279,9 @@ fn bucket_class(n: u64) -> usize { impl EdgeMemReport { pub fn bucket_histogram(&self) -> impl Iterator { - BUCKET_CLASS_BOUNDS.into_iter().zip(self.bucket_size_classes) + BUCKET_CLASS_BOUNDS + .into_iter() + .zip(self.bucket_size_classes) } } @@ -347,7 +364,9 @@ impl Sources { } } Self::Large(big) => { - if big.keys.remove(key) && let Some(a) = author { + if big.keys.remove(key) + && let Some(a) = author + { drop_author(&mut big.authors, a); } } @@ -675,9 +694,9 @@ impl EdgeStore { .and_then(|id| { self.forward.read_sync(&id, |_, sources| { let init = ScanState::with_capacity(limit_usize + 1); - let outcome = sources.directed(cursor, dir).try_fold( - init, - |mut state, key| { + let outcome = sources + .directed(cursor, dir) + .try_fold(init, |mut state, key| { if state.scanned >= scan_cap && state.matched.len() <= limit_usize { return ControlFlow::Break(state); } @@ -695,8 +714,7 @@ impl EdgeStore { } } ControlFlow::Continue(state) - }, - ); + }); let (state, bucket_exhausted) = match outcome { ControlFlow::Continue(s) => (s, true), ControlFlow::Break(s) => (s, false), diff --git a/bobbin/crates/edge-index/tests/bucket_scaling.rs b/bobbin/crates/edge-index/tests/bucket_scaling.rs index 62a49234..15fb5a8b 100644 --- a/bobbin/crates/edge-index/tests/bucket_scaling.rs +++ b/bobbin/crates/edge-index/tests/bucket_scaling.rs @@ -21,16 +21,15 @@ fn adversarial_keys(n: u32) -> Vec { fn vec_shift_work(keys: &[Key]) -> u128 { let mut sorted: Vec = Vec::with_capacity(keys.len()); - keys.iter().fold(0u128, |moves, &key| { - match sorted.binary_search(&key) { + keys.iter() + .fold(0u128, |moves, &key| match sorted.binary_search(&key) { Ok(_) => moves, Err(pos) => { let displaced = (sorted.len() - pos) as u128; sorted.insert(pos, key); moves + displaced } - } - }) + }) } thread_local! { @@ -63,9 +62,7 @@ fn btree_compare_work(keys: &[Key]) -> u128 { } fn doubling_ratios(work: &[u128]) -> Vec { - work.windows(2) - .map(|w| w[1] as f64 / w[0] as f64) - .collect() + work.windows(2).map(|w| w[1] as f64 / w[0] as f64).collect() } #[test] @@ -120,16 +117,15 @@ fn sorted_vec_build_is_quadratic_while_btree_is_quasilinear() { fn vec_remove_work(keys: &[Key]) -> u128 { let mut sorted: Vec = keys.to_vec(); sorted.sort_unstable(); - keys.iter().fold(0u128, |moves, key| { - match sorted.binary_search(key) { + keys.iter() + .fold(0u128, |moves, key| match sorted.binary_search(key) { Ok(pos) => { let displaced = (sorted.len() - pos - 1) as u128; sorted.remove(pos); moves + displaced } Err(_) => moves, - } - }) + }) } fn btree_remove_work(keys: &[Key]) -> u128 { diff --git a/bobbin/crates/record-lru/src/lib.rs b/bobbin/crates/record-lru/src/lib.rs index e4b09127..3507e288 100644 --- a/bobbin/crates/record-lru/src/lib.rs +++ b/bobbin/crates/record-lru/src/lib.rs @@ -99,10 +99,7 @@ impl Weighter, Stored> for ByteWeighter { Payload::Raw(bytes) => bytes.len(), Payload::Zstd { compressed, .. } => compressed.len(), }; - ENTRY_OVERHEAD - + payload as u64 - + key.as_ref().len() as u64 - + val.cid.as_ref().len() as u64 + ENTRY_OVERHEAD + payload as u64 + key.as_ref().len() as u64 + val.cid.as_ref().len() as u64 } } diff --git a/bobbin/crates/xrpc/tests/aggregation.rs b/bobbin/crates/xrpc/tests/aggregation.rs index 6d1a9b13..755c391e 100644 --- a/bobbin/crates/xrpc/tests/aggregation.rs +++ b/bobbin/crates/xrpc/tests/aggregation.rs @@ -767,7 +767,11 @@ async fn gone_item_is_evicted_so_count_converges_to_list() { ) .await; assert_eq!(status, StatusCode::OK); - assert_eq!(body["items"].as_array().unwrap().len(), 1, "gone item dropped from the page"); + assert_eq!( + body["items"].as_array().unwrap().len(), + 1, + "gone item dropped from the page" + ); let (cstatus, cbody) = json_response( app.oneshot(list_request( diff --git a/bobbin/default.nix b/bobbin/default.nix index c284cf2c..27b78a50 100644 --- a/bobbin/default.nix +++ b/bobbin/default.nix @@ -4,7 +4,6 @@ tangled, ... }: - rustPlatform.buildRustPackage { pname = "bobbin"; version = "main"; @@ -33,4 +32,3 @@ rustPlatform.buildRustPackage { mainProgram = "bobbin"; }; } - -- 2.51.2