fix!: remove LengthPrefix deref fallback that could silently drop length encoding - #48
Conversation
Co-authored-by: Altair-Bueno <67512202+Altair-Bueno@users.noreply.github.com>
LengthPrefix deref fallback that could silently drop length encoding
|
@copilot is there any combinator that has this issue too? We should fix any other deref that leads to the same bug |
Co-authored-by: Altair-Bueno <67512202+Altair-Bueno@users.noreply.github.com>
Yes—I audited all combinators with |
@copilot I would rather have it gone to avoid potential issues in the future. Are there any more Deref uses I missed? |
Co-authored-by: Altair-Bueno <67512202+Altair-Bueno@users.noreply.github.com>
Done in |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #48 +/- ##
===========================================
+ Coverage 99.43% 100.00% +0.56%
===========================================
Files 25 25
Lines 1067 1025 -42
===========================================
- Hits 1061 1025 -36
+ Misses 6 0 -6
🚀 New features to boost your workflow:
|
Removing the `Deref` impls also removed the `clone`/`default`/`from` tests, since they asserted through `*value`. Restore them using `as_ref()`/`into_inner()` and additionally cover `partial_cmp`, which was already uncovered before this branch. Fixes the codecov/project regression (99.43% -> 96.70%). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
LengthPrefixcould compile and run without writing a prefix whenLengthwas notEncodable(e.g.u32), because method resolution fell throughDerefto the wrapped value’sencode. This change removes that fallback so invalidLengthPrefixusage is rejected at compile time.API behavior change: remove
DerefonLengthPrefiximpl Deref for LengthPrefix<...>to prevent.encode()from auto-forwarding to the inner encodable whenLengthPrefixitself does not satisfyEncodablebounds.Regression guard: compile-fail coverage
trybuild-based UI test assertingLengthPrefix::<_, u32, _>::new("hello").encode(...)does not compile.Test cleanup aligned with API change
LengthPrefixunit tests that relied on deref semantics (*lpstyle assertions), preserving only behavior that remains part of the type’s API.Lengthis notEncodable(Deref shadows the failed impl) #47