Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(allocator/vec): remove ManuallyDrop wrapper #9742

Merged

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Mar 13, 2025

Partially revert #6623, It still keeps the check for non-drop element of Vec

Copy link
Member Author

Dunqing commented Mar 13, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

codspeed-hq bot commented Mar 13, 2025

CodSpeed Performance Report

Merging #9742 will not alter performance

Comparing 03-13-feat_allocator_vec_remove_manuallydrop_wrapper (caa477c) with main (65643bc)

Summary

✅ 33 untouched benchmarks

Copy link
Contributor

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from e5a1a8e to d1e11c1 Compare March 14, 2025 06:11
@Dunqing Dunqing marked this pull request as ready for review March 14, 2025 06:19
@graphite-app graphite-app bot force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch 2 times, most recently from a202e87 to fbba78c Compare March 14, 2025 06:22
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from d1e11c1 to 7403cdf Compare March 14, 2025 06:22
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from 7403cdf to 3812849 Compare March 14, 2025 06:24
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from fbba78c to 32f8347 Compare March 14, 2025 06:24
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from 3812849 to cc06e07 Compare March 14, 2025 07:44
@Dunqing Dunqing force-pushed the 03-11-feat_allocator_remove_drop_operations_from_vec2 branch from 32f8347 to dda7025 Compare March 14, 2025 07:44
@graphite-app graphite-app bot changed the base branch from 03-11-feat_allocator_remove_drop_operations_from_vec2 to graphite-base/9742 March 14, 2025 07:51
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 14, 2025
Copy link
Contributor

overlookmotel commented Mar 14, 2025

Merge activity

  • Mar 14, 3:51 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 14, 3:52 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 14, 4:06 AM EDT: A user merged this pull request with the Graphite merge queue.

@graphite-app graphite-app bot changed the base branch from graphite-base/9742 to main March 14, 2025 07:58
Partially revert #6623, It still keeps the check for non-`drop` element of `Vec`
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from cc06e07 to caa477c Compare March 14, 2025 07:59
@graphite-app graphite-app bot merged commit caa477c into main Mar 14, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants