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

RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute #45394

Merged
merged 5 commits into from Nov 4, 2017

Conversation

@davidtwco
Member

davidtwco commented Oct 19, 2017

This work-in-progress pull request contains my changes to implement RFC 2008. The related tracking issue is #44109.

As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored.

WIP PR requested by @nikomatsakis in Gitter.

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Oct 19, 2017

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Collaborator

rust-highfive commented Oct 19, 2017

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis
Contributor

nikomatsakis commented Oct 19, 2017

@petrochenkov petrochenkov self-assigned this Oct 19, 2017

@oli-obk

All the error-cases have a trivial solution. I think it would be cool if we also produced structured suggestions showing how to fix it

@oli-obk

This comment has been minimized.

Show comment
Hide comment
@oli-obk

oli-obk Oct 20, 2017

Contributor

tidy failed:

[00:03:26] tidy error: /checkout/src/test/compile-fail/rfc-2008-non-exhaustive/functional_record.rs:24: line longer than 100 chars
[00:03:26] tidy error: /checkout/src/librustc_privacy/lib.rs:632: line longer than 100 chars
[00:03:26] tidy error: /checkout/src/librustc_privacy/lib.rs:635: line longer than 100 chars
Contributor

oli-obk commented Oct 20, 2017

tidy failed:

[00:03:26] tidy error: /checkout/src/test/compile-fail/rfc-2008-non-exhaustive/functional_record.rs:24: line longer than 100 chars
[00:03:26] tidy error: /checkout/src/librustc_privacy/lib.rs:632: line longer than 100 chars
[00:03:26] tidy error: /checkout/src/librustc_privacy/lib.rs:635: line longer than 100 chars
@davidtwco

This comment has been minimized.

Show comment
Hide comment
@davidtwco

davidtwco Oct 20, 2017

Member

@oli-obk Thanks for the comments, I'll get on these ASAP.

Update: pushed up changes that fixed most everything mentioned including the tidy.

Member

davidtwco commented Oct 20, 2017

@oli-obk Thanks for the comments, I'll get on these ASAP.

Update: pushed up changes that fixed most everything mentioned including the tidy.

@davidtwco

This comment has been minimized.

Show comment
Hide comment
@davidtwco

davidtwco Oct 22, 2017

Member

@petrochenkov Thanks a bunch for the comments. Just fixed a bunch of them and I think there's one that I'm still working to resolve.

Member

davidtwco commented Oct 22, 2017

@petrochenkov Thanks a bunch for the comments. Just fixed a bunch of them and I think there's one that I'm still working to resolve.

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 3, 2017

Contributor

@davidtwco
Variants are not supported yet, but the attribute is still silently accepted on them.
Could you temporarily prohibit #[non_exhaustive] on variants in ast_validation.rs?

Contributor

petrochenkov commented Nov 3, 2017

@davidtwco
Variants are not supported yet, but the attribute is still silently accepted on them.
Could you temporarily prohibit #[non_exhaustive] on variants in ast_validation.rs?

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 3, 2017

Contributor

Almost ready, r=me after addressing the last round of comments and squashing commits.

Contributor

petrochenkov commented Nov 3, 2017

Almost ready, r=me after addressing the last round of comments and squashing commits.

@davidtwco

This comment has been minimized.

Show comment
Hide comment
@davidtwco

davidtwco Nov 3, 2017

Member

@petrochenkov That's all your comments resolved.

@bors r=petrochenkov

Member

davidtwco commented Nov 3, 2017

@petrochenkov That's all your comments resolved.

@bors r=petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 3, 2017

Contributor

@davidtwco: 🔑 Insufficient privileges: Not in reviewers

Contributor

bors commented Nov 3, 2017

@davidtwco: 🔑 Insufficient privileges: Not in reviewers

davidtwco added some commits Nov 3, 2017

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 3, 2017

Contributor

@bors r+

Contributor

petrochenkov commented Nov 3, 2017

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 3, 2017

Contributor

📋 Looks like this PR is still in progress, ignoring approval

Contributor

bors commented Nov 3, 2017

📋 Looks like this PR is still in progress, ignoring approval

@petrochenkov petrochenkov changed the title from [WIP] RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute to RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute Nov 3, 2017

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 3, 2017

Contributor

@bors r+

Contributor

petrochenkov commented Nov 3, 2017

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 3, 2017

Contributor

📌 Commit d3babe5 has been approved by petrochenkov

Contributor

bors commented Nov 3, 2017

📌 Commit d3babe5 has been approved by petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 4, 2017

Contributor

⌛️ Testing commit d3babe5 with merge 5fe8cd7...

Contributor

bors commented Nov 4, 2017

⌛️ Testing commit d3babe5 with merge 5fe8cd7...

bors added a commit that referenced this pull request Nov 4, 2017

Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov
RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute

This work-in-progress pull request contains my changes to implement [RFC 2008](rust-lang/rfcs#2008). The related tracking issue is #44109.

As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored.

WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 4, 2017

Contributor

💔 Test failed - status-travis

Contributor

bors commented Nov 4, 2017

💔 Test failed - status-travis

@kennytm

This comment has been minimized.

Show comment
Hide comment
@kennytm

kennytm Nov 4, 2017

Member

pretty test of run-pass/rfc-2008-non-exhaustive/enums.rs failed.

[01:16:34] ---- [pretty] run-pass/rfc-2008-non-exhaustive/enums.rs stdout ----
[01:16:34] 	
[01:16:34] error: pretty-printed source does not match expected source

Diff (a single empty line 😕):

--- expected
+++ actual
@@ -20,6 +20,7 @@
 [01:16:34]         NonExhaustiveEnum::Unit => 1,
 [01:16:34]         NonExhaustiveEnum::Tuple(_) => 2,
 [01:16:34] 
+[01:16:34] 
 [01:16:34]         // This particular arm tests that a enum marked as non-exhaustive
 [01:16:34]         // will not error if its variants are matched exhaustively.
 [01:16:34]         NonExhaustiveEnum::Struct { field } => field,
Member

kennytm commented Nov 4, 2017

pretty test of run-pass/rfc-2008-non-exhaustive/enums.rs failed.

[01:16:34] ---- [pretty] run-pass/rfc-2008-non-exhaustive/enums.rs stdout ----
[01:16:34] 	
[01:16:34] error: pretty-printed source does not match expected source

Diff (a single empty line 😕):

--- expected
+++ actual
@@ -20,6 +20,7 @@
 [01:16:34]         NonExhaustiveEnum::Unit => 1,
 [01:16:34]         NonExhaustiveEnum::Tuple(_) => 2,
 [01:16:34] 
+[01:16:34] 
 [01:16:34]         // This particular arm tests that a enum marked as non-exhaustive
 [01:16:34]         // will not error if its variants are matched exhaustively.
 [01:16:34]         NonExhaustiveEnum::Struct { field } => field,
@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 4, 2017

Contributor

This is a pretty-printer bug (#37199).
// ignore-pretty issue #37199 in the test will fix the issue.

Contributor

petrochenkov commented Nov 4, 2017

This is a pretty-printer bug (#37199).
// ignore-pretty issue #37199 in the test will fix the issue.

@petrochenkov

This comment has been minimized.

Show comment
Hide comment
@petrochenkov

petrochenkov Nov 4, 2017

Contributor

@bors r+

Contributor

petrochenkov commented Nov 4, 2017

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 4, 2017

Contributor

📌 Commit 86c62d0 has been approved by petrochenkov

Contributor

bors commented Nov 4, 2017

📌 Commit 86c62d0 has been approved by petrochenkov

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 4, 2017

Contributor

⌛️ Testing commit 86c62d0 with merge d762b1d...

Contributor

bors commented Nov 4, 2017

⌛️ Testing commit 86c62d0 with merge d762b1d...

bors added a commit that referenced this pull request Nov 4, 2017

Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov
RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute

This work-in-progress pull request contains my changes to implement [RFC 2008](rust-lang/rfcs#2008). The related tracking issue is #44109.

As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored.

WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Nov 4, 2017

Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing d762b1d to master...

Contributor

bors commented Nov 4, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing d762b1d to master...

@bors bors merged commit 86c62d0 into rust-lang:master Nov 4, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@davidtwco davidtwco deleted the davidtwco:rfc-2008 branch Nov 4, 2017

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 7, 2017

Contributor

Just saw that this landed, nice work @davidtwco !

Contributor

nikomatsakis commented Nov 7, 2017

Just saw that this landed, nice work @davidtwco !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment