-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute #44109
Comments
I'd cc @rust-lang/compiler instead. |
im working on a pr for this. how should tests be structured? |
also: should there be a lint for |
@tinaun shouldn't they all go under the |
@tinaun I would expect tests for this to be scattered about in the run-pass and compile-fail and ui directories:
Just to keep things organized, I would make a subdirectory like So I would imagine using ui tests to check for:
The run-pass might be used to test that an exhaustive match within the same crate compiles just fine. |
@tinaun any progress? need any tips? |
I'm currently away for the weekend but I would love to have some help with understanding the implementation of privacy in the complier. sorry for forgetting about this! |
So, this feature shouldn't require too many changes to implement.
|
@tinaun just checking in -- did those instructions help? Still got questions? =) UPDATE: @tinaun responded on Gitter. |
Hoping to take a stab at this after speaking with @nikomatsakis in Gitter. @tinaun are you still working on this? Update: @tinaun replied on Gitter. |
@nikomatsakis @eddyb @arielb1 @pnkfelix (I'm not sure who I should be pinging about this, apologies) So far I've implemented most of the mentoring instructions but there are a few things I've run into issues with. In this section where I require I've also not made changes to the visibilities in I hope this is on the right track and I'd appreciate any feedback. |
To check whether an ADT is within the same crate as the crate you are type-checking, find the def-id of the ADT and check whether it's local - e.g. if you have an |
For the visibility, you can ask @petrochenkov but I think you want to set the visibility to |
If you can find me, feel free to ping me on IRC. |
Thanks, that's super helpful. With regards to the visibility, that's what I was setting the visibility to, but I'll take another stab at it and see what I can come up with. |
@davidtwco glad to see that @arielb1 got you unblocked! Looking forward to seeing the PR. =) Let us know if you hit any other problems (are here or on gitter) |
Apologies for how long this is taking and for a further query. Since my previous comment here I think I've got it working with structs and after speaking with @nikomatsakis in Gitter earlier today, I've added a bunch more tests for cases that I hadn't considered. There are only five tests that still don't pass: The first of which is related to instantiating a tuple struct, I think I've went wrong with the visibility somewhere for this so I'm going to look into that. The second of which is similar but for instantiating a unit struct. The rest of which are all related to a lack of errors for things that should fail on enums with the attribute. @nikomatsakis mentioned that there are two cases with enums, handling new variants and new fields to existing variants - I do believe that the new fields case is handled by the existing structs code but I'm not 100% sure. However, I don't think the new variants case is handled. All the help so far as been fantastic so I appreciate that. |
@yodaldevoid I think the recording (and minutes) are available here |
This comment has been minimized.
This comment has been minimized.
@Kixunil that is how the feature works already. |
@Nemo157 ah I missed that, awesome! Thank you! |
This commit stabilizes RFC 2008 (rust-lang#44109) by removing the feature gate. Signed-off-by: David Wood <[email protected]>
This attribute replaces the _hidden field of the struct, serving the same purpose. For enums, we don't use the non_exhaustive feature yet as we'd like to have exhaustivness checks at least for our internal code. For more, see this comment by @dtolnay [1] It stabilized in Rust 1.40.0 which got released today. The MSRV policy of this crate is to follow whatever the currently latest released Rust version is. [1]: rust-lang/rust#44109 (comment)
They've done a lot of cleaning up upstream and are no longer pulling in stuff via commit hashes so we can remove all the _REV, DISTFILES, SITES and post-extract stuff for librespot, tremor, etc. - Back to having an odd SITES work-around for a CARGO_CRATE_DEPENDS: wasi-0.9.0 due to the version name. - Need [Rust 1.40][1] for this owing to [whoami-0.7.0][2] and use of `#[non_exhaustive]` per [this issue][3] - Back to having a patch for nix [per this commit][4] just because of the version being used (this is ultimately fixed upstream) - Most other patches can be (and have been) removed though [1]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1400-2019-12-19 [2]: https://github.com/libcala/whoami/blob/03b0b552f3732d1738b353415ef7dd7bb5555393/changelog.md#070---2019-12-21 [3]: rust-lang/rust#44109 [4]: https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commit;h=0a23b3b322a6313f27284baa499924921beeca73
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is not the place to discuss this. Please file a new issue for any problems you might have. |
This is a tracking issue for the RFC "Future-proofing enums/structs with #[non_exhaustive] attribute" (rust-lang/rfcs#2008).
Steps:
Issues to be resolved prior to stabilization
#[non_exhaustive]
is not yet implemented for enum variants.#[non_exhaustive(foo)]
) and in arbitrary locations, including suspicious ones like traits(#[non_exhaustive] trait Trait {}
).The text was updated successfully, but these errors were encountered: