Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

core: replace Once::data inner type to MaybeUninit #3206

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iamlockon
Copy link

There is a TODO suggesting we should use mem::uninitialized to replace Option, but since the suggested function is deprecated, we should use MaybeUninit instead. This PR makes exactly that change.

Motivation

I am learning tracing source code, and spotted this TODO and feel I might be able to help address this one.

Solution

Updated the Once::data inner type from Option<T> to MaybeUninit<T>.

There is a TODO suggesting we should use mem::uninitialized to replace
Option, but since the suggested function is deprecated, we should use
MaybeUninit instead. This PR makes exactly that change.

Signed-off-by: Jay Wang <xdddxyyyxzzz123@gmail.com>
@mladedav
Copy link
Contributor

mladedav commented Feb 5, 2025

Can't we just switch directly to OnceLock? We just need to update msrv to 1.70 which I think should be fine at this point.

@iamlockon
Copy link
Author

iamlockon commented Feb 6, 2025

Can't we just switch directly to OnceLock? We just need to update msrv to 1.70 which I think should be fine at this point.

On a closer look, I think we can't use OneLock as spin::Once is used for no-std (code) at the moment.

@Jesse-Bakker
Copy link

@iamlockon this code doesn't compile (cargo check -p tracing-core --no-default-features)

@iamlockon
Copy link
Author

@Jesse-Bakker Thanks for catching that! I missed it because I only tried cargo build locally..

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants