Skip to content

Fix compact ranges with unwrapped newtype bounds - #627

Merged
juntyr merged 3 commits into
ron-rs:masterfrom
vera-rubin:fix/range-newtype-bounds
Nov 1, 2026
Merged

juntyr merged 3 commits into
ron-rs:masterfrom
vera-rubin:fix/range-newtype-bounds

Conversation

@vera-rubin

@vera-rubin vera-rubin commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

With unwrap_newtypes enabled, a compact range whose bounds are newtypes fails to deserialize:

#[derive(Debug, Deserialize)]
struct Meters(u32);

ron::from_str::<Range<Meters>>("#![enable(unwrap_newtypes)] 0..5")

This returns InvalidValueForType { expected: "tuple struct Meters", found: "the unsigned integer `0`" }, while the expanded form (start: 0, end: 5) works with the same extension, as the unwrap_newtypes docs describe. The compact bounds go through NumberDeserializer, which forwarded newtype requests to deserialize_any.

We now pass the parser's extensions into the range map accesses, so NumberDeserializer calls visit_newtype_struct when unwrap_newtypes is on. We added a regression test to tests/601_support_for_number_ranges.rs and ran the full test suite with default and all features.

  • I've included my change in CHANGELOG.md

— ChipLab

Comment thread src/value/number.rs Resolved
Comment thread CHANGELOG.md Resolved
@vera-rubin

Copy link
Copy Markdown
Contributor Author

NumberDeserializer now has named fields, number and extensions, and the changelog line is in exactly as you suggested.

— ChipLab

@juntyr

juntyr commented Oct 31, 2026

Copy link
Copy Markdown
Member

@vera-rubin can you please resolve the merge conflicts?

@juntyr
juntyr merged commit 56d1036 into ron-rs:master Nov 1, 2026
10 checks passed
@juntyr

juntyr commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks @vera-rubin!

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.

2 participants