feat(allocator/vec): remove ManuallyDrop wrapper#9742
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 14, 2025
Merged
Conversation
This was referenced Mar 13, 2025
Member
Author
CodSpeed Performance ReportMerging #9742 will not alter performanceComparing Summary
|
Member
There was a problem hiding this comment.
Apart from the 2 comments below, this looks good.
We definitely need to keep the const { Self::ASSERT_T_IS_NOT_DROP } assertions. Vec itself is non-drop, but these assertions also make sure that T (what you put in the Vec) is also non-drop.
This prevents memory leaks because otherwise there'd be nothing stopping you creating, for example, a Vec<'a, std::string::String>.
{
let mut vec = Vec::new_in(&allocator);
vec.push("foobar".to_string());
// `vec` gets dropped here, but `Vec` doesn't implement `Drop`,
// so it doesn't drop the `String`.
// The 6 bytes of heap memory owned by the `String` is not reclaimed = memory leak.
}const { Self::ASSERT_T_IS_NOT_DROP } is a compile-time check which prevents this. The example above will refuse to compile due to this assertion.
e5a1a8e to
d1e11c1
Compare
a202e87 to
fbba78c
Compare
d1e11c1 to
7403cdf
Compare
7403cdf to
3812849
Compare
fbba78c to
32f8347
Compare
overlookmotel
approved these changes
Mar 14, 2025
3812849 to
cc06e07
Compare
32f8347 to
dda7025
Compare
Member
Merge activity
|
Partially revert #6623, It still keeps the check for non-`drop` element of `Vec`
cc06e07 to
caa477c
Compare
This was referenced Mar 18, 2025
perf(allocator/vec2): replace
self.reserve(1) calls with self.grow_one() for better efficiency
#9856
Merged
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.

Partially revert #6623, It still keeps the check for non-
dropelement ofVec