Skip to content
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

Implement Debug for MaybeUninit #65013

Open
wants to merge 1 commit into
base: master
from

Conversation

@petertodd
Copy link
Contributor

petertodd commented Oct 2, 2019

Precedent: UnsafeCell implements Debug even though it can't actually display the value. I noticed this omission while writing the following:

#[derive(Debug)]
 pub struct SliceInitializer<'a, T> {
    marker: PhantomData<&'a mut T>, 
    uninit: &'a mut [MaybeUninit<T>],
    written: usize,
}

...which currently unergonomically fails to compile.

UnsafeCell does require T: Debug. Because of things like the above I think it'd be better to leave that requirement off. In fact, I'd also suggest removing that requirement for UnsafeCell too, which again I noticed in some low-level real world code.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 2, 2019

r? @withoutboats

(rust_highfive has picked a reviewer for you, use r? to override)

@petertodd petertodd force-pushed the petertodd:2019-maybeuninit-debug branch from 9aab81b to 5fefbd1 Oct 2, 2019
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 2, 2019

src/libcore/mem/maybe_uninit.rs Outdated Show resolved Hide resolved
@RalfJung

This comment has been minimized.

Copy link
Member

RalfJung commented Oct 3, 2019

No objections from my side; this is mostly a T-libs question IMO.

@Centril Centril added this to the 1.40 milestone Oct 3, 2019
@Centril Centril added the relnotes label Oct 3, 2019
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 3, 2019

Updated labels accordingly :)

@JohnTitor

This comment has been minimized.

Copy link
Member

JohnTitor commented Oct 27, 2019

Ping from triage: @withoutboats could you review this?

@Centril Centril modified the milestones: 1.40, 1.41 Nov 7, 2019
@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Nov 7, 2019

@rfcbot fcp merge

I think it makes sense to me that this wouldn't need a T: Debug bound since there's no way we could ever actually display the T, but let's go through an FCP round to make sure people agree.

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Nov 7, 2019

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

src/libcore/mem/maybe_uninit.rs Outdated Show resolved Hide resolved
Precedent: UnsafeCell implements Debug even though it can't actually
display the value.
@petertodd petertodd force-pushed the petertodd:2019-maybeuninit-debug branch from edfd0fa to 8fad66b Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.