Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Closed
steffahn opened this issue Dec 5, 2024 · 0 comments · Fixed by #133889
Closed

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

steffahn opened this issue Dec 5, 2024 · 0 comments · Fixed by #133889
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

steffahn commented Dec 5, 2024

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

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 5, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 5, 2024
Consider fields to be inhabited if they are unstable

Fixes rust-lang#133885 with a simple heuristic

r? Nadrieril

Not totally certain if this needs T-lang approval or a crater run.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 5, 2024
Consider fields to be inhabited if they are unstable

Fixes rust-lang#133885 with a simple heuristic

r? Nadrieril

Not totally certain if this needs T-lang approval or a crater run.
@jieyouxu jieyouxu added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 5, 2024
@bors bors closed this as completed in d8e44b7 Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants