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

Use #[non_exhaustive] where appropriate #86592

Merged
merged 1 commit into from
Jun 25, 2021
Merged

Conversation

jhpratt
Copy link
Member

@jhpratt jhpratt commented Jun 24, 2021

Due to the std/alloc split, it is not possible to make alloc::collections::TryReserveError::AllocError non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from #[non_exhaustive]).

@rustbot label +C-cleanup +T-libs +S-waiting-on-review

Due to the std/alloc split, it is not possible to make
`alloc::collections::TryReserveError::AllocError` non-exhaustive without
having an unstable, doc-hidden method to construct (which negates the
benefits from `#[non_exhaustive]`.
@rustbot rustbot added C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 24, 2021
@JohnTitor
Copy link
Member

LGTM 👍
r? @JohnTitor @bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 24, 2021

📌 Commit 3f14f4b has been approved by JohnTitor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 24, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Jun 24, 2021
Use `#[non_exhaustive]` where appropriate

Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`).

`@rustbot` label +C-cleanup +T-libs +S-waiting-on-review
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 25, 2021
Use `#[non_exhaustive]` where appropriate

Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`).

`@rustbot` label +C-cleanup +T-libs +S-waiting-on-review
_priv: (),
}
#[non_exhaustive]
pub struct Guard;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this permit construction of Guard by users who can't access Guard's fields? Like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside of a crate, #[non_exhaustive] has no effect. To external users, you can effectively pretend there's a hidden private field. There's an RFC and presumably a fair amount of documentation about what this feature is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. My concern still applies equally much. rustc_metadata has a bunch of stuff in it, not just the dynamic loading utilities, and so there's still value in not (easily) allowing other code in rustc_metadata to accidentally shoot their foot off.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose, but I don't particularly see that being an issue given the code reviews done on any PR.

@nagisa
Copy link
Member

nagisa commented Jun 25, 2021

I'm not sure I follow the motivation for most of these changes, tbh.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 25, 2021
Rollup of 5 pull requests

Successful merges:

 - rust-lang#86330 (Change how edition based future compatibility warnings are handled)
 - rust-lang#86513 (Rustdoc: Do not list impl when trait has doc(hidden))
 - rust-lang#86592 (Use `#[non_exhaustive]` where appropriate)
 - rust-lang#86608 (chore(rustdoc): remove unused members of RenderType)
 - rust-lang#86624 (Update compiler-builtins)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9e46499 into rust-lang:master Jun 25, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jun 25, 2021
@jhpratt jhpratt deleted the non_exhaustive branch June 26, 2021 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants