Comments (2)
pub(restricted) is now stable. But I think it is still blocked by :vis
matcher (rust-lang/rust#41022) to allow a proper fix.
Currently the straightforward fix using :vis
causes an error in example_generated.rs
error: local ambiguity: multiple parsing options: built-in NTs vis ('vis') or 1 other option.
--> src/example_generated.rs:5:5
|
4 | / bitflags! {
5 | | /// This is the same `Flags` struct defined in the [crate level example](../index.html#example).
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | | /// Note that this struct is just for documentation purposes only, it must not be used outside
7 | | /// this crate.
... |
15 | | }
16 | | }
| |_- in this macro invocation
error: Could not compile `bitflags`.
(diff)
diff --git a/src/lib.rs b/src/lib.rs
index 1694837..356fba1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![feature(macro_vis_matcher)]
+
//! A typesafe bitmask flag generator useful for sets of C-style bitmask flags.
//! It can be used for creating typesafe wrappers around C APIs.
//!
@@ -305,16 +307,16 @@ pub extern crate core as _core;
/// ```
#[macro_export]
macro_rules! bitflags {
- ($(#[$attr:meta])* pub struct $BitFlags:ident: $T:ty {
+ ($(#[$attr:meta])* $vis:vis struct $BitFlags:ident: $T:ty {
$($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
}) => {
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
$(#[$attr])*
- pub struct $BitFlags {
+ $vis struct $BitFlags {
bits: $T,
}
- $($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+
+ $($(#[$Flag_attr])* $vis const $Flag: $BitFlags = $BitFlags { bits: $value };)+
__impl_bitflags! {
struct $BitFlags: $T {
@@ -322,24 +324,6 @@ macro_rules! bitflags {
}
}
};
- ($(#[$attr:meta])* struct $BitFlags:ident: $T:ty {
- $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr;)+
- }) => {
- #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
- $(#[$attr])*
- struct $BitFlags {
- bits: $T,
- }
-
- $($(#[$Flag_attr])* const $Flag: $BitFlags = $BitFlags { bits: $value };)+
-
- __impl_bitflags! {
- struct $BitFlags: $T {
- $($(#[$Flag_attr])* const $Flag = $value;)+
- }
- }
-
- };
}
from bitflags.
It looks like using :vis
here is unblocked now, right?
from bitflags.
Related Issues (20)
- More methods to work with uncorresponding bits HOT 5
- Policy for unstable dependencies HOT 10
- insert_if() and remove_if() HOT 2
- feat: Add Security Policy HOT 2
- Methods on generated flags types not being detected as const HOT 6
- can't use private derive macros HOT 6
- bitflags v2.2 incompatibility with mysql_common HOT 3
- Bitflags reverses order of multiline doc comments HOT 1
- Allow opting-out of `InternalBitFlags` `fmt`/`FromStr` impls? HOT 5
- Allow external impls of Bits and BitFlags HOT 12
- Reference actions by commit SHA HOT 2
- bitflags 2.3.0 breaks flags that refer to constants in separate impl blocks via `Self` HOT 1
- Clippy Lint Failures HOT 3
- Clippy warnings around "manual implementation of an assign operation" HOT 2
- Breaking change released as 2.3.0, which causes build failures on upgrade HOT 6
- Problems deriving serde after upgrading HOT 2
- Treatment of unknown bits in operators is inconsistent HOT 18
- Inconsistent debug output for flag with no bits HOT 4
- SWC - Update to 2.3.x causes incorrect output HOT 9
- Flagging supply-chain security issues HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitflags.