-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Remove Option from BufWriter #87171
Remove Option from BufWriter #87171
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
Actually, does this need any unsafe at all? Plain destructuring should work. |
No, destructuring by value for types impl'ing drop doesn't work - https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b5e4339d6b72e25199a3d02d47004108 |
25ff036
to
9aea03f
Compare
Fixed the merge conflict, I was accidentally 11k commits behind master 😅 |
let inner = ptr::read(&mut self.inner); | ||
let buf = ptr::read(&mut self.buf); | ||
let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) }; | ||
|
||
mem::forget(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OT: this makes me wonder if we should have a way to destructure a struct
that implements Drop
without running its drop
implementation (and maybe also a way with running it?). It feels bad having to use unsafe
for this kind of stuff since it's simple enough that the compiler should be able to guarantee its safety in the general case.
9aea03f
to
8837bf1
Compare
@bors r+ |
📌 Commit 8837bf1 has been approved by |
Rollup of 14 pull requests Successful merges: - rust-lang#86410 (VecMap::get_value_matching should return just one element) - rust-lang#86790 (Document iteration order of `retain` functions) - rust-lang#87171 (Remove Option from BufWriter) - rust-lang#87175 (Stabilize `into_parts()` and `into_error()`) - rust-lang#87185 (Fix panics on Windows when the build was cancelled) - rust-lang#87191 (Package LLVM libs for the target rather than the build host) - rust-lang#87255 (better support for running libcore tests with Miri) - rust-lang#87266 (Add testcase for 87076) - rust-lang#87283 (Add `--codegen-backends=foo,bar` configure flag) - rust-lang#87322 (fix: clarify suggestion that `&T` must refer to `T: Sync` for `&T: Send`) - rust-lang#87358 (Fix `--dry-run` when download-ci-llvm is set) - rust-lang#87380 (Don't default to `submodules = true` unless the rust repo has a .git directory) - rust-lang#87398 (Add test for fonts used for module items) - rust-lang#87412 (Add missing article) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #72925