Conversation
|
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
|
r=me with CI passing |
I still don't quite know how to prevent memory leak from reading the docs, I found this in the release notes. |
|
I think the right way to avoid a leak is cc @rust-lang/wg-unsafe-code-guidelines - how do you get a |
|
Turning the leak back into a Vec can be tricky and dangerous. If the leak() is |
|
The docs do not even guarantee that If recovering from the leak is an intended feature, that would require a new guarantee currently not made by the docs. |
|
Got it, thanks. So I think we should document that this is not currently supported; right now it seems to imply there's a way if only you figure it out: |
|
Maybe we should mention that there is no way to recover the leak unlike box? Since for box it show some methods to recover the leak but I don't see that for vec, maybe it would be good to mention it to be explicit. Sounds like a potential footgun, I feel like the function should be unsafe even though the word "leak" already feels scary enough. |
|
|
To elaborate on what @jyn514 said: "footgun" is not what
|
|
It can't cause UB but it can cause memory leak, so memory leak is safe? Yeah, I agree that causing UB is definitely unsafe but memory leak feels unsafe to me too. |
|
UB for Rust is defined here. Memory leaks indeed are not on that list. |
Should we clarify that memory leak won't be part of that list? |
|
Many things are not part of that list, listing them all could get exhausting. ;) For the PR, I agree the docs here should be clarified to say that there is no supported way to "undo the leak". |
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
|
@bors r+ rollup Thanks for the PR and starting a good discussion :) |
|
📌 Commit 8688fa8 has been approved by |
Link Vec leak doc to Box
Rollup of 10 pull requests Successful merges: - rust-lang#77195 (Link to documentation-specific guidelines.) - rust-lang#77629 (Cleanup of `eat_while()` in lexer) - rust-lang#77709 (Link Vec leak doc to Box) - rust-lang#77738 (fix __rust_alloc_error_handler comment) - rust-lang#77748 (Dead code cleanup in windows-gnu std) - rust-lang#77754 (Add TraitDef::find_map_relevant_impl) - rust-lang#77766 (Clarify the debug-related values should take boolean) - rust-lang#77777 (doc: disambiguate stat in MetadataExt::as_raw_stat) - rust-lang#77782 (Fix typo in error code description) - rust-lang#77787 (Update `changelog-seen` in config.toml.example) Failed merges: r? `@ghost`
No description provided.