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

use MaybeUninit instead of mem::uninitialized for Windows Mutex #56275

Merged
merged 10 commits into from
Dec 2, 2018

Conversation

RalfJung
Copy link
Member

I hope this builds, I do not have a Windows machine to test...

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 27, 2018
pub unsafe fn uninitialized() -> ReentrantMutex {
mem::uninitialized()
pub fn uninitialized() -> ReentrantMutex {
MaybeUninit::uninitialized()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you forgot to wrap this in ReentrantMutex.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot indeed, thanks!

@rust-highfive

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member

FWIW, you should be able to run the mingw-check builder locally (src/ci/docker/run.sh mingw-check I believe) if you have Docker.

Code-wise this seems fine but someone else should probably review as well as I'm not up to date on MaybeUninit myself -- not sure who to assign though personally.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@RalfJung
Copy link
Member Author

RalfJung commented Dec 2, 2018

Code-wise this seems fine but someone else should probably review as well as I'm not up to date on MaybeUninit myself -- not sure who to assign though personally.

@SimonSapin could you have a look?

@@ -22,6 +22,9 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
unsafe {
let mut buf = MaybeUninit::<[u8; 1024]>::uninitialized(); // enough for f32 and f64
let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninitialized();
// FIXME: Technically, this is calling `get_mut` on an uninitialized
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe file an issue about this specifically, and mention that issue number in code comments for all known occurences? That way when the question is resolved we can grep for the issue number to find places to fix (or to remove outdated FIXME comments).

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't this usually be part of the discussion in the tracking issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, the tracking issue number could serve as well. My comment was more about having something to grep for to find known occurrences.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. Is like this okay? This covers all get_mut uses that got added as part of my PR series. I grepped the codebase for other uses of MaybeUninit and found none.

@SimonSapin
Copy link
Contributor

Looks good, thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Dec 2, 2018

📌 Commit ebe69c0 has been approved by SimonSapin

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 2, 2018
@bors
Copy link
Contributor

bors commented Dec 2, 2018

⌛ Testing commit ebe69c0 with merge 8660eba...

bors added a commit that referenced this pull request Dec 2, 2018
use MaybeUninit instead of mem::uninitialized for Windows Mutex

I hope this builds, I do not have a Windows machine to test...
@bors
Copy link
Contributor

bors commented Dec 2, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: SimonSapin
Pushing 8660eba to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants