Check for uninhabitedness instead of never#54123
Closed
varkor wants to merge 1 commit intorust-lang:masterfrom
Closed
Check for uninhabitedness instead of never#54123varkor wants to merge 1 commit intorust-lang:masterfrom
varkor wants to merge 1 commit intorust-lang:masterfrom
Conversation
oli-obk
reviewed
Sep 11, 2018
| }; | ||
| if cx.layout_of(sig.output()).abi == ty::layout::Abi::Uninhabited { | ||
| // Tell LLVM that functions that return uninhabited types will not return. | ||
| if sig.output().conservative_is_uninhabited() { |
Contributor
There was a problem hiding this comment.
isn't this way more conservative than the layout check? I think this should stay being the layout check. It does not influence type checking, just llvm optimizations
| let llfn = declare_raw_fn(cx, name, fty.llvm_cconv(), fty.llvm_type(cx)); | ||
|
|
||
| if cx.layout_of(sig.output()).abi == layout::Abi::Uninhabited { | ||
| if sig.output().conservative_is_uninhabited() { |
| // into an uninhabited type is impossible, so anything following | ||
| // it must be unreachable. | ||
| assert_eq!(bx.cx.layout_of(sig.output()).abi, layout::Abi::Uninhabited); | ||
| assert!(sig.output().conservative_is_uninhabited()); |
Contributor
There was a problem hiding this comment.
similarly here, the previous assert was stronger
Contributor
Author
Contributor
|
Ah makes sense, still not sure if these PRs can be reviewed independently |
Contributor
Author
|
Yeah, in retrospect, the order of dependency would work better flipped. @nikomatsakis: it might make sense to review #54125 directly (as that PR includes the changes here) instead. |
Contributor
Author
|
Closing this PR in favour of merging #54125. |
bors
added a commit
that referenced
this pull request
Sep 26, 2018
…, r=<try> Less conservative uninhabitedness check Extends the uninhabitedness check to structs, non-empty enums, tuples and arrays. Pulled out of #47291 and #50262. Blocked on #54123. r? @nikomatsakis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of checking for
!, in many places we can simply check that a type is uninhabited.Pulled out of #47291 and #50262.
r? @nikomatsakis