This repository was archived by the owner on Jun 8, 2021. It is now read-only.
Merged
Conversation
Member
|
Thanks, also note that this is seems done internally too rust-lang/rust#62150 |
sdroege
reviewed
Jul 12, 2019
src/boxed.rs
Outdated
| Boxed { | ||
| inner: { | ||
| let mut inner = Box::<T>::new(mem::zeroed()); | ||
| let mut inner = Box::<T>::new(mem::MaybeUninit::zeroed().assume_init()); |
Member
There was a problem hiding this comment.
This is wrong again and defeats the purpose of MaybeUninit. This code here has to be
let mut inner = Box::<T>::new(mem::MaybeUninit::zeroed();
MM::init(inner.as_mut_ptr());
AnyBox::Native(inner.assume_init());
sdroege
reviewed
Jul 12, 2019
sdroege
reviewed
Jul 12, 2019
sdroege
reviewed
Jul 12, 2019
src/object.rs
Outdated
| fn downgrade(&self) -> WeakRef<T> { | ||
| unsafe { | ||
| let w = WeakRef(Box::new(mem::zeroed()), PhantomData); | ||
| let w = WeakRef(Box::new(mem::MaybeUninit::zeroed().assume_init()), PhantomData); |
Member
There was a problem hiding this comment.
Same
let w = Box::new(mem::MaybeUninit::zeroed());
gobject_sys::g_weak_ref_init(
mut_override((&mut *w).as_mut_ptr()),
self.as_object_ref().to_glib_none().0,
);
// Or maybe this line can be *w = (&mut *w).assume_init()?
ptr::write(&mut *w, ptr::read(&*w).assume_init());
WeakRef(w)
sdroege
reviewed
Jul 12, 2019
src/object.rs
Outdated
| pub fn new() -> WeakRef<T> { | ||
| unsafe { | ||
| let w = WeakRef(Box::new(mem::zeroed()), PhantomData); | ||
| let w = WeakRef(Box::new(mem::MaybeUninit::zeroed().assume_init()), PhantomData); |
sdroege
reviewed
Jul 12, 2019
sdroege
reviewed
Jul 12, 2019
src/time_val.rs
Outdated
| impl Uninitialized for TimeVal { | ||
| unsafe fn uninitialized() -> TimeVal { | ||
| mem::zeroed() | ||
| mem::MaybeUninit::zeroed().assume_init() |
Member
There was a problem hiding this comment.
As we want to get rid of this trait anyway, just leave it as mem::zeroed(). What you write is exactly equivalent to it apart from being more keypresses.
sdroege
reviewed
Jul 12, 2019
src/value.rs
Outdated
| impl Uninitialized for Value { | ||
| unsafe fn uninitialized() -> Value { | ||
| Value(mem::zeroed(), PhantomData) | ||
| Value(mem::MaybeUninit::zeroed().assume_init(), PhantomData) |
Member
Author
|
Updated. However, I'm absolutely not sure that this code is correct. I find this new rust API very bad... |
Member
|
On 12 July 2019 23:56:13 EEST, Guillaume Gomez ***@***.***> wrote:
Updated. However, I'm **absolutely** not sure that this code is
correct. I find this new rust API very bad...
I'll review this and the other ones tomorrow evening.
Personally I think the new API is much clearer. You can't accidentally use something uninitialized and it's absolutely clear at which point things are actually initialized. It's much safer compared to before, which was basically like in C and not very Rust-like.
…--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
sdroege
reviewed
Jul 14, 2019
sdroege
reviewed
Jul 14, 2019
sdroege
reviewed
Jul 14, 2019
Member
Author
|
Updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'll resume the regenerations of all other crates tomorrow.
cc @EPashkin @sdroege