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

VecView: fix memory leak of drop #465

Merged
merged 2 commits into from
May 24, 2024

Conversation

sosthene-nitrokey
Copy link
Contributor

In the initial implementation, I implemented Drop for Vec but I implemented it as a no-op for VecView, thinking that it should only be dropped through Vec.

This is incorrect, VecView can be responsible for dropping its content when its owned, for example in a Box.

This PR adds a test that fails with the current implementation, showing the memory leak, and fixes it by implementing Drop properly for VecView

Drop must also be implemented on `VecView` for the cases wher the `VecView` is owned
even if it is `!Sized`.

This can happen when it is boxed.
This represent more clearly the role of the trait now that it's not used
to work around drop specialization.
@reitermarkus reitermarkus added this pull request to the merge queue May 24, 2024
Merged via the queue into rust-embedded:main with commit 1f25e65 May 24, 2024
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants