Skip to content

Box the TableTypeMismatch and TypeDefinitionChanged details, and report the requested types - #1642

Merged
cberner merged 1 commit into
masterfrom
claude/sweet-hypatia-m4vct7-type-mismatch
Nov 9, 2026
Merged

cberner merged 1 commit into
masterfrom
claude/sweet-hypatia-m4vct7-type-mismatch

Conversation

@cberner

@cberner cberner commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

TableTypeMismatch reported only the types a table is stored with, as {table} is of type Table<K, V>. Two problems:

  • The niche case reads as a contradiction. A table of Option<&str> written by redb 2.6, opened with redb 5's niche Option<&str>, failed with values is of type Table<u64, Option<&str>>, which is exactly the type the caller asked for. The stored spelling and the niche spelling print the same in that message.
  • Multimap tables were mislabelled. A multimap table opened with the wrong types was also described as Table<..>.

Changes:

  • Wording, in both modes: the message no longer names the table type: {table} has key type K and value type V.

  • Under experimental-api-5: the TableTypeMismatch and TypeDefinitionChanged variants of TableError and Error hold a boxed struct, TableTypeMismatch or TypeDefinitionInfo, with private fields and accessors:

    • TableTypeMismatch: table(), stored_key(), stored_value(), requested_key(), requested_value().
    • TypeDefinitionInfo: name(), alignment(), width().

    Boxing makes TableError and Error 32 bytes, down from 88 on master. With the requested types inline they would have been 152, over clippy's result_large_err limit at 20 functions. Private fields mean later releases can add to the structs without a break.

  • New message under the feature: the message adds the requested types: values has key type u64 and value type Option<&str>, but was opened with key type u64 and value type niche::Option<&str>.

  • Without the feature, the variants keep their 4.x fields; only the wording above changes.

  • Construction goes through TableError::type_mismatch() and type_definition_changed(), so table_tree_base.rs has no cfgs.

  • Patterns: existing TableTypeMismatch { .. } patterns still compile against the tuple variants.

Tests:

  • niche_tests: checks the exact message on a real table written by redb 2.6.
  • multimap_tests: checks the wording in both modes.
  • basic_tests: checks the accessors and the message for a u32/NonZeroU32 mismatch.

Checked:

  • cargo fmt.
  • clippy --all --all-targets, with and without --all-features.
  • clippy for thumbv7em (no_std).
  • cargo doc.
  • cargo test --all-features and cargo test with default features: the full suites before review, and the lib tests plus niche, multimap and basic tests after the review changes.
  • The no_std regression crate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ALhxet6NP69dCfAUv8TAhR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T03:19:17.046731Z 1f2b002 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cberner
cberner force-pushed the claude/sweet-hypatia-m4vct7-type-mismatch branch from b2ac52b to 832a023 Compare November 9, 2026 01:52
Comment thread src/error.rs Resolved
Comment thread src/error.rs Resolved
Comment thread src/error.rs Resolved
…rt the requested types

A TableTypeMismatch reported only the types a table was stored with, and
named it Table<..> even when it was a multimap table. For a table of
Option<T> written before T declared a niche, the stored name prints the
same as the type the caller asked for, which made the error read as a
contradiction.

The message no longer names the table type. Under experimental-api-5
the TableTypeMismatch and TypeDefinitionChanged variants of TableError
and Error hold a boxed TableTypeMismatch or TypeDefinitionInfo, with
accessors, and TableTypeMismatch also reports the requested key and
value types. Boxing keeps both error enums at 32 bytes, and private
fields let later releases add to them.

Assisted-by: Claude Code
Claude-Session: https://claude.ai/code/session_01ALhxet6NP69dCfAUv8TAhR
@cberner
cberner force-pushed the claude/sweet-hypatia-m4vct7-type-mismatch branch from 832a023 to 1f2b002 Compare November 9, 2026 03:18
@cberner
cberner merged commit ca08ded into master Nov 9, 2026
5 checks passed
@cberner
cberner deleted the claude/sweet-hypatia-m4vct7-type-mismatch branch November 9, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant