Skip to content

Now-safe cpuid triggers unused_unsafe #1990

Open

Description

@mkroening

@joshtriplett wrote in rust-lang/rust#146560 (comment):

That said, counterproposal: rather than a target feature, can we transition to cpuid being universally safe (using the mechanisms we normally use to move something from unsafe to safe without provoking widespread warnings about unused unsafe)?

cpuid currently triggers unused_unsafe (see rust-osdev/x86_64#575). Is this intentional?

Activity

  1. RalfJung commented on Jan 7, 2026

    @RalfJung
    Member

    Thanks for reporting this! This seems like an oversight indeed. Cc @sayantn

    That said, I am honestly not entirely sure which mechanisms Josh is referring to here...

  2. tgross35 commented on Jan 7, 2026

    @tgross35
    Member

    I think the unused_unsafe is actually useful here - isn't it useful to know that those functions can get rid of their only unsafe block?

  3. mkroening commented on Jan 8, 2026

    @mkroening
    Author

    Yes, that's useful. Though, it requires allowing the lint on crates that support older rust versions where unsafe is needed. For me it is fine either way. I just wanted to make sure this is not an oversight.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions