Skip to content

fix: resolve type inference failures in docx parser and fictionbook extractor (#622)#624

Merged
Goldziher merged 1 commit into
mainfrom
fix/issue-622-type-inference-regression
Apr 1, 2026
Merged

fix: resolve type inference failures in docx parser and fictionbook extractor (#622)#624
Goldziher merged 1 commit into
mainfrom
fix/issue-622-type-inference-regression

Conversation

@kh3rld

@kh3rld kh3rld commented Mar 31, 2026

Copy link
Copy Markdown
Member

Summary

Second occurrence of the type inference regression class fixed in #519.

Two missed sites in docx/parser.rs matched attr.value.as_ref() without an explicit as &[u8] cast. The compiler locked the inferred type to &[u8; 5] from the first arm (b"begin"), then rejected b"separate" (8 bytes) and b"end" (3 bytes) with E0308. The prior fix in #519 caught e.name().as_ref() call sites but missed the attr.value.as_ref() pattern.

Two sites in fictionbook.rs called .as_ref() on a Cow<'_, str> without an explicit &str annotation, producing E0282 on newer toolchains where type inference is stricter.

Changes

  • extraction/docx/parser.rs: added as &[u8] cast at both attr.value.as_ref() match sites (lines 1282 and 1416)
  • extractors/fictionbook.rs: added : &str annotation to both let trimmed = normalized.as_ref() bindings (lines 112 and 831)

Test plan

  • cargo check -p kreuzberg passes (verified locally)
  • cargo test -p kreuzberg — docx and fictionbook extraction tests pass
  • Reporter can build against this patch on Rust 1.94.0-aarch64-apple-darwin

Closes #622

…xtractor

Second occurrence of the class of issue fixed in #519. Two sites in
docx/parser.rs matched attr.value.as_ref() without an explicit &[u8] cast,
causing the compiler to lock the type to &[u8; 5] from the first arm and
reject the other arms ("separate" = 8 bytes, "end" = 3 bytes).
Two sites in fictionbook.rs called normalized.as_ref() on a Cow<str> without
an explicit &str annotation, triggering E0282 on newer toolchains.

Fixes #622
@kh3rld kh3rld requested a review from Goldziher March 31, 2026 21:39
@kh3rld kh3rld moved this from Todo to In Review in Kreuzberg.dev Kanban Mar 31, 2026
@Goldziher Goldziher merged commit 8c6904d into main Apr 1, 2026
16 of 68 checks passed
@Goldziher Goldziher deleted the fix/issue-622-type-inference-regression branch April 1, 2026 08:31
@github-project-automation github-project-automation Bot moved this from In Review to Done in Kreuzberg.dev Kanban Apr 1, 2026
Goldziher added a commit that referenced this pull request Apr 2, 2026
…ce-regression

fix: resolve type inference failures in docx parser and fictionbook extractor (#622)
Goldziher added a commit that referenced this pull request May 17, 2026
…ce-regression

fix: resolve type inference failures in docx parser and fictionbook extractor (#622)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

bug: Can't build kreuzberg since version 4.4.1

2 participants