fix: explicit slice coercion in MotionPhoto attribute comparison#58
Merged
Conversation
Comparing `extract_attr_value()` (which returns `Option<&[u8]>`) against byte-string literals relied on automatic unsizing coercion from `&[u8; N]` to `&[u8]`. This coercion fails to apply when a crate like rkyv is present in the dependency graph, since its blanket `PartialEq<ArchivedOption<T>>` impl introduces an additional trait resolution candidate and the coercion target is no longer unambiguous. Force the slice type explicitly so the comparison compiles regardless of other crates in the graph.
mindeng
approved these changes
May 28, 2026
Owner
mindeng
left a comment
There was a problem hiding this comment.
LGTM. Clean fix — the explicit slice coercion resolves the rkyv blanket impl ambiguity without any behavior change. Tests (366 passed) and clippy are clean.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
==========================================
- Coverage 90.33% 89.84% -0.49%
==========================================
Files 38 38
Lines 8212 8399 +187
==========================================
+ Hits 7418 7546 +128
- Misses 794 853 +59
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cargo clippy/cargo buildfails insrc/jpeg.rswhen rkyv is presentelsewhere in the dependency graph:
extract_attr_value()returnsOption<&[u8]>, while the literalsSome(b"MotionPhoto")andSome(b"video/mp4")areOption<&[u8; N]>. The comparison normally works because Rust coercesthe array reference to a slice — but that coercion only fires when the target type is unambiguous.
rkyv's blanket impl
adds another
PartialEqcandidate, so coercion no longer applies and the literal stays&[u8; N], for which no matching impl exists.Fix
Coerce the literals to slices explicitly:
This makes the comparison type-correct on its own, independent of any other crate in the graph.
Notes