-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Discourage overuse of mem::forget #53503
Conversation
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup |
📌 Commit 2fae6e2ae114cd9e7dc1a1d4e415eab57c19ca3e has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The build failure seems to be from unrelated commit. |
@bors r- This PR caused UI test failure in #53530 (comment). That UI test contains some line numbers from |
I filed #53547 to fix the brittle test. For now @kornelski 😭 it looks like you will need to find the new line number and update const-size_of-cycle.stderr in this PR. (Or fix #53547 yourself if you are up for it?) |
Fix for the other test is now merged. I've rebased this. |
@bors r+ rollup |
📌 Commit e7709b3 has been approved by |
Discourage overuse of mem::forget Some uses of `mem::forget` have been replaced by better methods of `Box`, so I've removed obsoleted use-cases from these docs. I've removed emphasis on leaking, because it's not obvious `mem::forget` does not guarantee leaking of memory: memory of stack-allocated objects and values partially moved out of `Box` will still be freed. That's a potential error when used to pass objects to FFI, so it's better to direct users to `Box::into_raw` instead.
Rollup of 16 pull requests Successful merges: - #53311 (Window Mutex: Document that we properly initialize the SRWLock) - #53503 (Discourage overuse of mem::forget) - #53545 (Fix #50865: ICE on impl-trait returning functions reaching private items) - #53559 (add macro check for lint) - #53562 (Lament the invincibility of the Turbofish) - #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()) - #53592 (docs: minor stylistic changes to str/string docs) - #53594 (Update RELEASES.md to include clippy-preview) - #53600 (Fix a grammatical mistake in "expected generic arguments" errors) - #53614 (update nomicon and book) - #53617 (tidy: Stop requiring a license header) - #53618 (Add missing fmt examples) - #53636 (Prefer `.nth(n)` over `.skip(n).next()`.) - #53644 (Use SmallVec for SmallCStr) - #53664 (Remove unnecessary closure in rustc_mir/build/mod.rs) - #53666 (Added rustc_codegen_llvm to compiler documentation.)
Some uses of
mem::forget
have been replaced by better methods ofBox
, so I've removed obsoleted use-cases from these docs.I've removed emphasis on leaking, because it's not obvious
mem::forget
does not guarantee leaking of memory: memory of stack-allocated objects and values partially moved out ofBox
will still be freed. That's a potential error when used to pass objects to FFI, so it's better to direct users toBox::into_raw
instead.