Skip to content

Likely unintentionally stabilized support for inhabitedness checks to permeate Pin #133885

Closed
@steffahn

Description

@steffahn
use std::pin::Pin;

enum Void {}
fn demo(x: Pin<Void>) {
    match x {}
}

this compiles successfully since 1.82

The issue with this is that generally, the check does not look through private implementation details. However, the field of Pin is technically public (only hidden and unstable) in order to support the pin! macro.

I would have expected the above code to still fail compiling. It’s quite unlikely that anyone depends on this behavior already, because Pin isn’t supposed to be used with non-pointers anyway.

This could be fixed by changing the inhabitedness check to treat unstable fields like private fields.

Alternatively, if kept as-is, we should add a test case for this so we at least notice the breakage if Pin is ever re-structured to no longer using a public field.

cc @Nadrieril, I guess

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language 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