-
Notifications
You must be signed in to change notification settings - Fork 149
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
Support for additional access specifiers #126
Conversation
Nice work! Thanks @GabrielMajeri. I'm not sure if we've got an idea of when Also worth noting that once it does stabilise and we do merge then the minimum |
This can go in behind a cargo feature, right? |
@tamird yes it can, I've now placed it behind the |
Hmm, I'm not personally sold on the need for a Do you have any thoughts @alexcrichton? |
I don't follow, @KodrAus. Using a cargo feature allows this to merge before the necessary bits are stabilized upstream. Bumping the minimum rust version is a separate discussion - there's no reason to hold this up on that decision. |
Yep, sorry @tamird I was getting ahead of myself 😅 Feel free to ignore all of that until |
Oh I figured we'd just add support when this is in stable rust, but I don't think it is? |
Yeh it looks like it's still unstable. I was originally thinking we shouldn't release with a cargo feature because then we'd have to maintain a fork of the macro, and people shouldn't need to use a feature to get But I think we could use a feature, and then when it does stabilise we could just make that feature a no-op, since the I guess the alternative is not use a feature and let this PR sit here waiting until it can work on stable, but I don't know when that would be. |
That's true yeah, I'd also be ok landing it behind an off-by-default feature. |
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.
I would prefer to do this in a way that immediately works on stable. Would something like this be possible?
/*
#![feature(macro_vis_matcher)]
macro_rules! m {
($vis:vis const $n:ident) => {
$vis const $n: i32 = 0;
};
}
*/
macro_rules! m {
(const $n:ident) => {
__impl_m!(() const $n);
};
(pub const $n:ident) => {
__impl_m!((pub) const $n);
};
(pub ($($vis:tt)+) const $n:ident) => {
__impl_m!((pub ($($vis)+)) const $n);
};
}
macro_rules! __impl_m {
(($($vis:tt)*) const $n:ident) => {
$($vis)* const $n: i32 = 0;
};
}
m!(const PRIV);
m!(pub(crate) const CRATE);
m!(pub const PUB);
fn main() {
println!("{} {} {}", PRIV, CRATE, PUB);
}
Neat! What do you think @GabrielMajeri? |
Was removed when merging upstream changes
Superseded by #135. |
This pull request adds support for new access specifiers like
pub (crate)
orpub (in some_module)
.This is currently a
nightly
only feature, so this pull request should not currently be merged.It breaks all doctests and integration tests, since they'd need to manually enable
#![feature(macro_vis_matcher)]
.Fixes #72 (once merged).