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

feature-gate uninhabited checks #39192

Closed
nikomatsakis opened this issue Jan 19, 2017 · 9 comments
Closed

feature-gate uninhabited checks #39192

nikomatsakis opened this issue Jan 19, 2017 · 9 comments
Labels
P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

Per the discussion on internals, we want to ensure that the recent improvements to uninhabited types are feature-gated. There was #39151, but that only applies to &Void, whereas it seems prudent to try to feature-gate the changes to uninhabited checks more broadly.

cc @eddyb @arielb1 @canndrew

@nikomatsakis
Copy link
Contributor Author

triage: P-high

@rust-highfive rust-highfive added the P-high High priority label Jan 19, 2017
@nikomatsakis nikomatsakis added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 19, 2017
@nikomatsakis
Copy link
Contributor Author

Marking as P-high because we want to reach a state we are all happy with before next beta.

@nikomatsakis
Copy link
Contributor Author

I'm not sure on just what the algorithm did before the change -- I believe that it specifically handled a case where you wrote match foo { } and foo was considered uninhabited? So if we wanted to reproduce just that behavior, we would disable the "new" uninhabited check, but retain the older one?

The main case I am wondering about is stuff like where a Void is found inside a field that may (or may not) be accessed. e.g., is (i32, Void) uninhabited? Seems like that is not entirely clear in unsafe code (for same reason as &*). But I have to refresh my memory for the conversation and don't have a chance just now.

@arielb1
Copy link
Contributor

arielb1 commented Jan 19, 2017

The old algorithm regarded all types as inhabited, except that an empty match was special cased.

About uninhabitableness: I am quite sure you should not be having invalid values. Stuff like nonstandard booleans in an (u32, bool) will cause UB by LLVM range assert even today. That means that (i32, Void) is truly uninhabited.

@djzin
Copy link
Contributor

djzin commented Jan 19, 2017

I find it helpful to think of ! / Void as not being a zero-sized type; rather it could be thought of as having "negative infinity" size, being log(0) bits in size. From this perspective (i32, Void) doesn't "feel" like it should exist since you are juxtaposing a type with 32 bits next to negative infinity bits, and the infinite wins out.

@nikomatsakis
Copy link
Contributor Author

Fixed by #39151

@nikomatsakis
Copy link
Contributor Author

Er, #39290

@nikomatsakis nikomatsakis reopened this Jan 26, 2017
@nikomatsakis
Copy link
Contributor Author

Not yet landed, so I'll leave it open.

@nikomatsakis
Copy link
Contributor Author

Landed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants