Skip to content

Replace std::io::lazy::Lazy with a copy of lazy-static's similar, but Once-using, type. #53646

Closed
@eddyb

Description

@eddyb

It's not clear why std::io::lazy doesn't use Once, as that was available at the time when it was introduced.

#53108 marked Lazy::new as unsafe because of the lack of reentrance safety in the mutex being used, but Once specifically doesn't have reentrancy issues.

lazy_static version: https://github.com/rust-lang-nursery/lazy-static.rs/blob/13159c2b615903d93b4cd4f98d17fdfe70392a3a/src/inline_lazy.rs

However, we need to change it per rust-lang-nursery/lazy-static.rs#117, otherwise it's unsound.

cc @RalfJung @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions