← Back to Pull requests

fix(monty): compile the JSON string cache on the declared 1.96 MSRV #1013

Closed
unknown closed this pull request without merging on Oct 12, 2026 08:58 UTC
View on GitHub
unknown unknown commented on Oct 10, 2026 04:29 UTC
Author

Fixes #985.

Problem

CacheInner::entries is a Box<[CacheEntry; CAPACITY]> (CAPACITY = 16_384).
drop_all iterates it with a reference to the Box itself:

for entry in &mut inner.entries {

A for loop calls IntoIterator::into_iter on the expression as written, with
no auto-deref, so this needs &mut Box<[T; N]>: IntoIterator. That impl does not
exist on the rustc releases at or below the rust-version = "1.96" declared in
Cargo.toml, and the loop fails to compile:

error[E0277]: `[Option<(u64, Box<str>, Value)>; 16384]` is not an iterator
  --> crates/monty/src/modules/json/string_cache.rs:98
   |
98 |             for entry in &mut inner.entries {
   |                  ^^^^^^^^^^^^ `[Option<(u64, Box<str>, Value)>; 16384]` is not an iterator

Fix

Dereference the Box so the loop borrows the array, and [T; N] has implemented
IntoIterator for &mut [T; N] since Rust 1.53:

for entry in &mut *inner.entries {

This is a one-line, source-compatible change. Behaviour is unchanged: the loop
still visits every one of the CAPACITY slots and keeps the existing
entry.take() / value.drop_with(heap) sequence, including the
value.drop_with(heap) ordering guarantee that cached values must be dropped
while the heap is still alive (it is called from VM::drop() before teardown).

I used &mut *inner.entries rather than inner.entries.iter_mut() because the
workspace lints against the pedantic group, which includes
clippy::explicit_iter_loop — that attribute would fire on the .iter_mut()
spelling.

Verification

  • cargo check -p monty --lib passes on rustc 1.99.0 both before and after, so

  • this is a strict addition and does not regress current toolchains.
  • The failing pattern was confirmed with an isolated reproducer, where the only

  • difference between the two spellings is the deref:

      let mut entries: Box<[u64; 16384]> = Box::new([0; 16384]);
      for entry in &mut entries { ... }        // E0277 on rustc 1.85.1
      for entry in &mut *entries { ... }       // compiles on 1.85.1 and 1.99.0
      

  • clippy-driver --edition=2024 -W clippy::pedantic (with the same allows listed

  • in the workspace Cargo.toml) reports nothing on the new loop.

    No other source file is touched.

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Fixes the monty JSON string cache so it builds on the declared 1.96 MSRV. The teardown loop in drop_all iterated &mut Box<[T; N]>, which only gained an IntoIterator impl on newer rustc and caused E0277; dereferencing the box borrows the array itself, which has supported IntoIterator for &mut [T; N] since Rust 1.53. Behavior is unchanged: the loop still visits all CAPACITY slots and preserves the entry.take() / value.drop_with(heap) sequence so values are dropped before the heap is torn down. The deref spelling is used rather than .iter_mut() because the workspace's pedantic lint set would flag the latter.

    <sup>Written for commit da3cddea48b3f5995d51868b16b3a0a75b07e9f1. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1013?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 456 lines (+342 / -114) across 5 files Reviewer: rewitt94 Review duration: 3148m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 456 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1013"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%
    Repository