-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow type aliases in enumeration repr attributes. #1605
Conversation
Are there any potential issues with public type aliases from another module being used in an attribute? I'm not aware of anywhere else that name lookup of that sort occurs in an attribute context (although I could be horribly off base on this). |
@eddyb mentioned that this is currently not possible, because of syntax restrictions. However, if I understood him correctly, this problem will resolve itself due to some other changes to the language. I do not know whether I should have mentioned that in the RFC. My naive reasoning was: if the rfc is accepted, then necessary changes to the syntax will get implemented along the way. |
Just to put some meat on the bones, so to speak, here's an example piece of code where this would help. I've been writing rust for about 5 days, and, the first time I used extern crate libc;
use self::libc::c_int;
#[repr(c_int)]
pub enum Facility
{
LOG_KERN = self::libc::LOG_KERN,
// ... Omitted ...
} (Note, For me, this change is important because:-
|
|
The current state of the RFC proposes As another example, as @raphaelcohn provided one, I refer to my PR nix-rust/nix#362. |
Sorry if it's already been addressed, but I didn't see anyone mention this when I skimmed: The syntax Alternately, this RFC could lend more weight to @nrc's plans to make attribute syntax more free-form. |
So, this basically seems harmless to me, but there are some implementation complexities to overcome. For example, we'd want this to integrate well with hygiene. |
Hear ye, hear ye! This RFC is now entering final comment period with an inclination to close. We discussed in the @rust-lang/lang meeting and decided that while the RFC is well-motivated, it doesn't sufficiently address the various implementation complexities that must be overcome nor the interaction with hygiene. It would make sense to extend the attribute system to support more general paths before considering this RFC (but that is a non-trivial undertaking). @rust-lang/lang members, please check off your name to signal agreement. Leave a comment with concerns or objections. Others, please leave comments. Thanks!
|
Based on the reasoning in the previous comment, we're going to close this PR:
Thanks @fiveop for the proposal. |
Allows type aliases of rust integer types to be used in
#[repr(...)]
attributes of C-like enumerations to specify variant representation.Rendered