Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Conversation

GuillaumeGomez
Copy link
Member

I'll resume the regenerations of all other crates tomorrow.

cc @EPashkin @sdroege

@EPashkin
Copy link
Member

Thanks, also note that this is seems done internally too rust-lang/rust#62150

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

src/time_val.rs Outdated
impl Uninitialized for TimeVal {
unsafe fn uninitialized() -> TimeVal {
mem::zeroed()
mem::MaybeUninit::zeroed().assume_init()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

src/value.rs Outdated
impl Uninitialized for Value {
unsafe fn uninitialized() -> Value {
Value(mem::zeroed(), PhantomData)
Value(mem::MaybeUninit::zeroed().assume_init(), PhantomData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@GuillaumeGomez
Copy link
Member Author

Updated. However, I'm absolutely not sure that this code is correct. I find this new rust API very bad...

@sdroege
Copy link
Member

sdroege commented Jul 13, 2019 via email

@GuillaumeGomez
Copy link
Member Author

Updated.

@sdroege sdroege merged commit 28831d1 into gtk-rs:master Jul 15, 2019
@GuillaumeGomez GuillaumeGomez deleted the zeroed branch July 15, 2019 12:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants