Skip to content

Replace usage of mem::uninitialized with MaybeUninit #2532

Closed

Description

@memoryruins

When the following comment was added in #1845, hyper's minimum supported rust version was 1.27.0

// `mem::uninitialized` replaced with `mem::MaybeUninit`,
// can't upgrade yet
#![allow(deprecated)]

which I assume is why std::mem::MaybeUninit, stabilized in 1.36.0, could not be used yet. Today, hyper's MSRV is 1.46.0, so it should now be possible to investigate removing the #![allow(deprecated)].

Activity

  1. seanmonstar commented on May 4, 2021

    @seanmonstar
    Member

    Good call!

  2. added
    A-http1Area: HTTP/1 specific.
    E-easyEffort: easy. A task that would be a great starting point for a new contributor.
    C-refactorCategory: refactor. This would improve the clarity of internal code.
    on May 4, 2021
  3. mohsen-alizadeh commented on May 4, 2021

    @mohsen-alizadeh
    Contributor

    Refactored the code.

  4. Soveu commented on May 4, 2021

    @Soveu
    Contributor

    One problem with refactoring the code is that httparse::Request::new accepts &mut [Header], so it is assumed that they are initialized. It would need to accept &mut [MaybeUninit<Header>]

    Otherwise MaybeUninit::uninit().assume_init() (like it is done here) gives the same problems as mem::uninitialized

  5. RalfJung commented on Jul 21, 2021

    @RalfJung
    Contributor

    FYI, this seems to be one of the major sources of regressions in rust-lang/rust#87041.

  6. added a commit that references this issue on Aug 19, 2021
    95a9783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-http1Area: HTTP/1 specific.C-refactorCategory: refactor. This would improve the clarity of internal code.E-easyEffort: easy. A task that would be a great starting point for a new contributor.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions