-
Notifications
You must be signed in to change notification settings - Fork 1.1k
libc: make structs non_exhaustive by default. #4579
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
base: main
Are you sure you want to change the base?
Conversation
5af4be6
to
d10b5ad
Compare
/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not | ||
/// make sense, and for unions. | ||
macro_rules! s { | ||
($( | ||
$(#[@$not_non_exhaustive:ident])* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be able to match a literal, right?
$(#[@$not_non_exhaustive:ident])* | |
$(#[not_non_exhaustive])? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it fails with "attempted to repeat an expression containing no syntax variables"
d10b5ad
to
12de1ba
Compare
The errors are strange, is it because |
Yeah, that's the kind of random problem we run into with the current ctest. Completely unrelated changes make random failures show up, especially related to macros The rewrite will be quite nice :) |
12de1ba
to
687c202
Compare
For platforms where ctest has been upgraded, like apple, problems similar to #4651 appear (but not consistently for all of them). Also the current implementation of the macro doesn't seem to work very well either, causing unused attribute errors. Link to the issue in Rust: rust-lang/rust#132699 |
Description
By default all structs that use the
s
ands_no_extra_traits
macros are nownon_exhaustive
. Structs can opt out of this if their first attribute is#[@not_non_exhaustive]
.The
@
was necessary so that Rust could differentiate between a normal attribute (which cannot have an@
) and this. Another possible syntax that we could use instead is#[@not(non_exhaustive)]
.Sources
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI