Skip to content

Fix invalid_data_error! macro to properly format error messages with arguments#84

Merged
sile merged 4 commits intomasterfrom
fix-issue-82
Feb 15, 2026
Merged

Fix invalid_data_error! macro to properly format error messages with arguments#84
sile merged 4 commits intomasterfrom
fix-issue-82

Conversation

@sile
Copy link
Owner

@sile sile commented Feb 15, 2026

The invalid_data_error! macro was dropping variadic format arguments ($arg), so error messages lost runtime context (for example, values like method=0).

Changes

  • Fixed the single-argument arm to construct InvalidData errors directly.
  • Fixed the variadic arm for std builds to format messages with ::alloc::format!($fmt, ...).
  • Added cfg handling so no_std builds remain compatible with core2::io::Error::new (which requires &'static str in that mode).
  • Added a regression test for issue invalid_data_error drops $arg #82 (zlib::tests::issue_82) to ensure formatted values appear in error messages.

Closes #82

@sile sile merged commit d59a94d into master Feb 15, 2026
38 checks passed
@sile sile deleted the fix-issue-82 branch February 15, 2026 11:19
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.

invalid_data_error drops $arg

1 participant