build(deps): upgrade cached 0.59 -> 2.0.2#1203
Draft
reubeno wants to merge 2 commits into
Draft
Conversation
Migrate the `cached` dependency across its 0.x -> 1.x -> 2.x breaking changes (latest published 2.x is 2.0.2): - proc-macro path `cached::proc_macro::cached` -> `cached::macros::cached` - `size = N` -> `max_size = N` on every `#[cached]` - drop `result = true` (Result-returning cached fns now skip caching `Err` by default, preserving prior behavior) - `SizedCache` -> `LruCache`; the removed `with_size()` constructor becomes `LruCache::builder().max_size(64).build()` While here, take advantage of the macro's default key being built by cloning the args: switch the parser cached fns (arithmetic/word/tokenizer) to borrowed arguments with explicit `key`/`convert`, eliminating a redundant caller-side `.to_owned()` on every call (halves clones for those hot paths). Cascade `&str` through the prompt and parsing chains so no `#[allow]`s are needed. regex.rs: `build()` is now fallible but unwrap/expect/panic are all denied, so wrap the thread-local LRU cache in `Option` and build via `.build().ok()`, gracefully degrading to uncached regex compilation if construction ever fails. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
@copilot please fix formatting to fix format check PR check failures. |
Contributor
Fixed in commit style: apply cargo fmt to brush-core — |
Performance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades the
cacheddependency from0.59.0to2.0.2(the latest published 2.x) in bothbrush-coreandbrush-parser, working through the 0.x → 1.x → 2.x breaking changes.Migration
cached::proc_macro::cached→cached::macros::cachedsize = N→max_size = Non every#[cached]result = true—Result-returning cached fns now skip cachingErrby default (prior behavior preserved)SizedCache→LruCache; removedwith_size()constructor →LruCache::builder().max_size(64).build()Clone reductions (bonus)
The default
#[cached]key is built by cloning the args, so any function whose caller did.to_owned()just to pass owned args was cloning twice per call. Switched the parser cached fns (arithmetic/word/tokenizer) to borrowed args with explicitkey/convert, moving the single needed clone into key-construction — halves clones on those hot paths (and on cache hits removes the redundant caller-side clone). Cascaded&strthrough the prompt and parsing chains so no#[allow]s are needed.The prompt/parsing chains genuinely need their owned values (
.into_owned()is borrow-checker-mandated against&mut self;parse_string'sInto<String>bound forces materialization), so those save no clones — documented in the commit rather than papered over.regex.rs
build()is now fallible, butunwrap/expect/panicare all denied lints. The thread-local LRU cache is nowOption<LruCache>built via.build().ok(), gracefully degrading to uncached regex compilation if construction ever fails (never happens with a fixedmax_size, but no panic).Testing
cargo build --workspace✅cargo clippy -p brush-parser -p brush-core✅ (pedantic/nursery/cargo/perf all denied)cargo test -p brush-parser -p brush-core✅ (all pass)🤖 Generated with Claude Code