-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Consider references and unions potentially inhabited during privacy-respecting inhabitedness checks #56110
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
Merged
Merged
Consider references and unions potentially inhabited during privacy-respecting inhabitedness checks #56110
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
682f0f8
Consider references and unions potentially inhabited during privacy-r…
varkor d2b3407
Add a test for uninhabitedness changes
varkor 32a8dec
Clarify undecided semantics
varkor 46ef9f8
Fix broken tests
varkor 1cdf5df
Fix error message after rebase
varkor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// The precise semantics of inhabitedness with respect to unions and references is currently | ||
// undecided. This test file currently checks a conservative choice. | ||
|
||
#![feature(exhaustive_patterns)] | ||
#![feature(never_type)] | ||
|
||
#![allow(dead_code)] | ||
#![allow(unreachable_code)] | ||
|
||
pub union Foo { | ||
foo: !, | ||
} | ||
|
||
fn uninhab_ref() -> &'static ! { | ||
unimplemented!() | ||
} | ||
|
||
fn uninhab_union() -> Foo { | ||
unimplemented!() | ||
} | ||
|
||
fn match_on_uninhab() { | ||
match uninhab_ref() { | ||
//~^ ERROR non-exhaustive patterns: type `&'static !` is non-empty | ||
} | ||
|
||
match uninhab_union() { | ||
//~^ ERROR non-exhaustive patterns: type `Foo` is non-empty | ||
} | ||
} | ||
Centril marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
fn main() {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0004]: non-exhaustive patterns: type `&'static !` is non-empty | ||
--> $DIR/always-inhabited-union-ref.rs:23:11 | ||
| | ||
LL | match uninhab_ref() { | ||
| ^^^^^^^^^^^^^ | ||
| | ||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
--> $DIR/always-inhabited-union-ref.rs:23:11 | ||
| | ||
LL | match uninhab_ref() { | ||
| ^^^^^^^^^^^^^ | ||
|
||
error[E0004]: non-exhaustive patterns: type `Foo` is non-empty | ||
--> $DIR/always-inhabited-union-ref.rs:27:11 | ||
| | ||
LL | match uninhab_union() { | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
--> $DIR/always-inhabited-union-ref.rs:27:11 | ||
| | ||
LL | match uninhab_union() { | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0004`. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.