[pointer] Fix bug in try_cast_into_no_leftover#2937
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2937 +/- ##
==========================================
+ Coverage 92.21% 92.29% +0.07%
==========================================
Files 19 19
Lines 5860 5868 +8
==========================================
+ Hits 5404 5416 +12
+ Misses 456 452 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f0fa851 to
71f7209
Compare
This was referenced Jan 28, 2026
4f7ace4 to
c75ac98
Compare
71f7209 to
04b7eed
Compare
c75ac98 to
9c4c755
Compare
7f5c72a to
71c76fb
Compare
9c4c755 to
ca91310
Compare
d749a54 to
2555a94
Compare
ca91310 to
62ba5db
Compare
2555a94 to
4029dea
Compare
62ba5db to
d21e64f
Compare
b0fa89d to
0b725a6
Compare
a251055 to
9b6af27
Compare
0b725a6 to
0752d5f
Compare
9b6af27 to
c5c6edd
Compare
0752d5f to
3d46f9f
Compare
c5c6edd to
f6656e5
Compare
f442a98 to
04486ac
Compare
jswrenn
approved these changes
Jan 29, 2026
Base automatically changed from
G7f73f342a0126d5f9b9dc44925f6ae7451034bef
to
main
January 29, 2026 16:42
04486ac to
49aafa2
Compare
Previously, `Ptr::try_cast_into_no_leftover` used the following logic to
recover the original `Ptr` in the case of failure:
```rust
match self.try_cast_into(CastType::Prefix, meta) {
Ok((slf, remainder)) => {
if remainder.len() == 0 {
Ok(slf)
} else {
// Undo the cast so we can return the original bytes.
let slf = slf.as_bytes();
```
This is incorrect: In the case that `remainder.len() > 0`, `slf` no
longer refers to the same referent as it did originally, as there are
remainder bytes (either in the prefix or the suffix). In this commit, we
use `Ptr::try_with` to restore the original `Ptr` exactly.
gherrit-pr-id: G27c254ea62bb8b789e4fcd4a2e9e09a74676b45a
49aafa2 to
d3359ba
Compare
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.
Previously,
Ptr::try_cast_into_no_leftoverused the following logic torecover the original
Ptrin the case of failure:This is incorrect: In the case that
remainder.len() > 0,slfnolonger refers to the same referent as it did originally, as there are
remainder bytes (either in the prefix or the suffix). In this commit, we
use
Ptr::try_withto restore the originalPtrexactly.transmute_{ref,mut}!#2943try_transmute_{ref,mut}!#2944try_cast_into_no_leftover#2937Latest Update: v23 — Compare vs v22
📚 Full Patch History
Links show the diff between the row version and the column version.
Stacked PRs enabled by GHerrit.