repo
stringclasses
1 value
pull_number
int64
24
411
instance_id
stringlengths
21
22
issue_numbers
listlengths
1
2
base_commit
stringlengths
40
40
patch
stringlengths
348
114k
test_patch
stringlengths
393
86.1k
problem_statement
stringlengths
285
2.62k
hints_text
stringlengths
0
2.14k
created_at
stringlengths
20
20
version
stringclasses
10 values
bitflags/bitflags
411
bitflags__bitflags-411
[ "406" ]
9c4b93c931e34a5104f50e20be1bdd15bc593b0e
diff --git a/src/lib.rs b/src/lib.rs index 8f722591..b5e8911b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,7 @@ bitflags! { See the docs for the `bitflags` macro for the full syntax. -Also see the [`example_generated`] module for an example of what the `bitflags` macro generates for a flags type. +Also se...
diff --git a/tests/compile-pass/bitflags_impl_attrs.rs b/tests/compile-pass/bitflags_impl_attrs.rs new file mode 100644 index 00000000..91d89823 --- /dev/null +++ b/tests/compile-pass/bitflags_impl_attrs.rs @@ -0,0 +1,13 @@ +extern crate bitflags; + +struct Example(u64); + +bitflags::bitflags! { + /// Docs on the `i...
Allow specifying attributes in `impl` mode I'm considering `cfg`-gating the use of `bitflags!` in my libraries, and to that end it would be nice if it was possible to apply attributes to the generated `impl`s as well. The naive solution would be: ```rust pub struct Flags(u8); #[cfg(feature = "bitflags")] bitfl...
Thanks for the report @madsmtm! Anywhere attributes are allowed to be specified we should support in the macros as much as possible. I think this is just a missing piece of functionality for the impl mode.
2024-06-24T23:17:40Z
2.5
bitflags/bitflags
380
bitflags__bitflags-380
[ "378" ]
472e392c0d082c0894b18fb31f4e68e0b145e29c
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e5edec86..4f4c6c1d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -84,18 +84,19 @@ jobs: cd ./tests/smoke-test cargo +$msrv build - mips: - name: Tests / MIPS (Big Endian) + miri: + na...
diff --git a/src/tests/iter.rs b/src/tests/iter.rs index 889ebcb7..54b1d27d 100644 --- a/src/tests/iter.rs +++ b/src/tests/iter.rs @@ -3,6 +3,7 @@ use super::*; use crate::Flags; #[test] +#[cfg(not(miri))] // Very slow in miri fn roundtrip() { for a in 0u8..=255 { for b in 0u8..=255 { diff --git a/sr...
Documenting bitflags: how to get documentation for the generated bitflags Some code that I'm writing uses the `#![warn(missing_docs)]` macro to enforce a requirement that all public interfaces have documentation. I haven't been able to figure out how to generate documentation when using the `bitflags!` macro; I also ha...
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=530756068e54aa56eb519dd66c9fdfc5 https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f782c74e49e8c4c4ae940125265eb7ed Thanks @rusty-snake! Those would actually make some great compile-pass tests 🤔
2023-10-09T04:48:32Z
2.4
bitflags/bitflags
366
bitflags__bitflags-366
[ "364" ]
09f71f492d0f76d63cd286c3869c70676297e204
diff --git a/examples/custom_bits_type.rs b/examples/custom_bits_type.rs index 0364a2bd..8924bfdf 100644 --- a/examples/custom_bits_type.rs +++ b/examples/custom_bits_type.rs @@ -1,6 +1,6 @@ use std::ops::{BitAnd, BitOr, BitXor, Not}; -use bitflags::{Flags, Flag, Bits}; +use bitflags::{Bits, Flag, Flags}; // Defi...
diff --git a/src/tests.rs b/src/tests.rs new file mode 100644 index 00000000..cb41f75a --- /dev/null +++ b/src/tests.rs @@ -0,0 +1,107 @@ +mod all; +mod bits; +mod complement; +mod contains; +mod difference; +mod empty; +mod eq; +mod extend; +mod flags; +mod fmt; +mod from_bits; +mod from_bits_retain; +mod from_bits_tr...
Inconsistent debug output for flag with no bits In a bitflags type where one of the named value has the value 0, the debug output for the type sometimes includes that value by name, and sometimes doesn't, apparently depending on whether any unrecognized bits are present. For example, this: ```rust use bitflags::bitfl...
The value `0` isn’t recommended as a flag value because it behaves surprisingly with formatting, and with `is_any`. If you do want to define a zero-valued flag I’d suggest defining the constant outside of the `bitflags!` macro.
2023-06-26T07:21:41Z
2.3
bitflags/bitflags
355
bitflags__bitflags-355
[ "357" ]
31d3e4afefc964045156d7fe3622733f48511353
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6ebd5a74..15d1f950 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -81,6 +81,23 @@ jobs: - name: Default features run: cross test --target mips-unknown-linux-gnu + clippy: + name: Clippy + run...
diff --git a/tests/compile-fail/bitflags_custom_bits.rs b/tests/compile-fail/bitflags_custom_bits.rs index 46fde469..b719de4f 100644 --- a/tests/compile-fail/bitflags_custom_bits.rs +++ b/tests/compile-fail/bitflags_custom_bits.rs @@ -19,7 +19,7 @@ use std::{ }, }; -use bitflags::{bitflags, Bits, parser::{Parse...
Clippy warnings around "manual implementation of an assign operation" Hi. I've run into a new clippy lint warnings such as the following: > manual implementation of an assign operation > for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern > `#[warn(clippy::a...
2023-05-17T11:22:15Z
2.3
bitflags/bitflags
351
bitflags__bitflags-351
[ "348" ]
1d8388bf4ce18afde846d220ad8b6e0dc40aae94
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a32e1d55..6ebd5a74 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,40 +10,21 @@ permissions: jobs: check: - name: "Tests / OS: ${{ matrix.os }} - ${{ matrix.channel }}-${{ matrix.rust_target }}" - runs...
diff --git a/tests/compile-fail/visibility/private_flags.rs b/tests/compile-fail/access_outside_visibility.rs similarity index 100% rename from tests/compile-fail/visibility/private_flags.rs rename to tests/compile-fail/access_outside_visibility.rs diff --git a/tests/compile-fail/visibility/private_flags.stderr b/tests...
Allow external impls of Bits and BitFlags The `BitFlags` trait is currently sealed, and is only supported through the `bitflags!` macro. I think we should make this trait publicly implementable, and default most of its members. I spent some time hacking on this, and came up with this minimal implementation. Given a ...
As for `Bits`, it can be reasonably reduced to: ```rust pub trait Bits: Clone + Copy + BitAnd<Output = Self> + BitOr<Output = Self> + BitXor<Output = Self> + Not<Output = Self> + PartialEq + Sized + 'static { /// The value of `Self` where no bits are set. cons...
2023-05-04T06:16:51Z
2.2
bitflags/bitflags
345
bitflags__bitflags-345
[ "344" ]
cbcafa710fc31172511e62efa06ad9eb214e4734
diff --git a/src/example_generated.rs b/src/example_generated.rs index 9c1ba46a..b7589014 100644 --- a/src/example_generated.rs +++ b/src/example_generated.rs @@ -33,8 +33,17 @@ __impl_public_bitflags! { __impl_public_bitflags_consts! { Flags { + /// Field `A`. + /// + /// This flag has the...
diff --git a/tests/compile-pass/large.rs b/tests/compile-pass/large.rs new file mode 100644 index 00000000..a7519f2a --- /dev/null +++ b/tests/compile-pass/large.rs @@ -0,0 +1,311 @@ +/* +Copyright (c) 2016 Anatoly Ikorsky + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software...
Bitflags reverses order of multiline doc comments When compiling code like ``` bitflags! { pub struct AdjustFlags: u32 { /// Add buf.time to the current time. If buf.status includes the ADJ_NANO flag, then buf.time.tv_usec is interpreted as a nanosecond value; /// otherwise it is interpreted as...
This should be trivially fixed by swapping the order attributes are "pushed" in `__declare_bitflags`. We've already yanked `2.2.0` because it requires a lot more recursion, but will keep this open to make sure any new approach doesn't reverse the order of attributes.
2023-04-24T04:29:26Z
2.2
bitflags/bitflags
341
bitflags__bitflags-341
[ "308" ]
dc971042c8132a5381ab3e2165983ee7f9d44c63
diff --git a/src/lib.rs b/src/lib.rs index 7ba784c5..a4a40467 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -558,6 +558,315 @@ macro_rules! bitflags { } $($t:tt)* + ) => { + __declare_bitflags!( + $(#[$outer])* + $vis struct $BitFlags: $T { + $( + ...
diff --git a/tests/compile-pass/doc_alias.rs b/tests/compile-pass/doc_alias.rs new file mode 100644 index 00000000..8fe1d900 --- /dev/null +++ b/tests/compile-pass/doc_alias.rs @@ -0,0 +1,14 @@ +#[macro_use] +extern crate bitflags; + +bitflags! { + #[doc(alias = "FLAG")] + pub struct Flags: u8 { + #[doc(al...
Cannot use `#[doc(alias)]` The following code: ```rs bitflags::bitflags! { #[doc(alias = "SYMBOLIC_LINK_FLAGS")] pub struct SymbolicLinkFlags:u32 { #[doc(alias = "SYMBOLIC_LINK_FLAG_DIRECTORY")] const DIRECTORY = 0x1; #[doc(alias = "SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE")] const ALLOW...
This is a general problem for attributes that can't be applied to expressions now. In methods like `from_name` we now generate code like this: ```rust #[inline] pub fn from_name(name: &str) -> ::bitflags::__private::core::option::Option<Self> { match name { #[doc(alias = "SYMBOLIC_LINK_FLAG_DIRECTORY...
2023-04-18T00:36:26Z
2.1
bitflags/bitflags
282
bitflags__bitflags-282
[ "228" ]
810dc35aba3df7314de01b93c7aa137968e925d4
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b7b2486e..f00ed6c2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -46,8 +46,17 @@ jobs: profile: minimal toolchain: ${{ matrix.channel }}-${{ matrix.rust_target }} - - name: Tests - run: c...
diff --git a/tests/basic.rs b/tests/basic.rs index 73a52bec..790ec41c 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -4,13 +4,14 @@ use bitflags::bitflags; bitflags! { /// baz + #[derive(Debug, PartialEq, Eq)] struct Flags: u32 { const A = 0b00000001; #[doc = "bar"] const...
Add an option for checking for valid bits is in the getter rather than constructor Hi, I want to use bitflags for generated code that interacts with data in other languages, some of which are bitflags (https://github.com/google/flatbuffers/pull/6098). I don't want to drop data so I'd like to use `from_bits_unchecked`. ...
Related: #188, #200, #207, #208, #211 @niklasf @KodrAus worked on #200 Bump! I'll do the PR if needed Hi @CasperN! :wave: We can't consider any changes to the `bits()` method, because the library is already stable. The way we modeled this originally was that the flags represents a closed enum, where the set s...
2022-05-25T04:14:38Z
1.3
bitflags/bitflags
281
bitflags__bitflags-281
[ "215" ]
f38ce72d11ef3e264d4b62f360bd8a5597b916d9
diff --git a/src/bitflags_trait.rs b/src/bitflags_trait.rs index 0ffee465..440d5274 100644 --- a/src/bitflags_trait.rs +++ b/src/bitflags_trait.rs @@ -1,3 +1,5 @@ +use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not}; + #[doc(hidden)] pub trait ImplementedByBitFlagsMacro {} @@ -5,7 +...
diff --git a/tests/compile-fail/cfg/multi.stderr b/tests/compile-fail/cfg/multi.stderr deleted file mode 100644 index be9ba21c..00000000 --- a/tests/compile-fail/cfg/multi.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0428]: the name `FOO` is defined multiple times - --> tests/compile-fail/cfg/multi.rs:6:1 - | -6 |...
Debug formatting leads to less desireable output [Link to rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=%23%5Bmacro_use%5D%0Aextern%20crate%20bitflags%3B%0A%0Abitflags!%20%7B%0A%20%20%20%20struct%20Flags%3A%20u32%20%7B%0A%20%20%20%20%20%20%20%20const%20A%20%3D%200b00000001%3B%...
I think the current algorithm used for debug output is to loop over all flags and append identifiers that correspond to set bits. I think an alternative here that could work would be to short-circuit when we’ve built a format that covers all the set bits. As an implementation note we wouldn’t be able to work off a sing...
2022-05-03T06:59:46Z
1.3
bitflags/bitflags
276
bitflags__bitflags-276
[ "275" ]
0141a07e55184304857384b0093d00959f0acfa6
diff --git a/src/lib.rs b/src/lib.rs index ab7656e7..b9d77f7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -559,10 +559,11 @@ macro_rules! __impl_bitflags { /// representation contains bits that do not correspond to a flag. #[inline] pub const fn from_bits(bits: $T) -> $crate::_cor...
diff --git a/tests/compile-fail/non_integer_base/all_defined.stderr.beta b/tests/compile-fail/non_integer_base/all_defined.stderr.beta index 6fada425..0607f234 100644 --- a/tests/compile-fail/non_integer_base/all_defined.stderr.beta +++ b/tests/compile-fail/non_integer_base/all_defined.stderr.beta @@ -49,8 +49,41 @@ er...
from_bits accepts non existing flags ```rs #[test] fn test_from_bits_edge_cases() { bitflags! { struct Flags: u8 { const A = 0b00000001; const BC = 0b00000110; } } let flags = Flags::from_bits(0b00000100); asse...
2022-04-19T09:54:30Z
1.3
bitflags/bitflags
268
bitflags__bitflags-268
[ "267" ]
1aa25e1b3baf35d3d3840f12fe7e8b55adc0164a
diff --git a/src/lib.rs b/src/lib.rs index 617afea0..b24fb40b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -494,8 +494,7 @@ macro_rules! __impl_bitflags { f.write_str(" | ")?; } first = false; - f.write_str("0x")?; - ...
diff --git a/tests/compile-fail/trait/custom_impl.rs b/tests/compile-fail/trait/custom_impl.rs index 66875898..80be2f91 100644 --- a/tests/compile-fail/trait/custom_impl.rs +++ b/tests/compile-fail/trait/custom_impl.rs @@ -62,4 +62,4 @@ impl BitFlags for BootlegFlags { } } -fn main() { } +fn main() {} diff --gi...
Bug: debug pretty-printing unknown flags display 0x0x main.rs ```rust use bitflags::bitflags; bitflags! { struct Flags: u8 { const TWO = 0x2; } } fn main() { let value = 0b11; let flags = unsafe { Flags::from_bits_unchecked(value) }; println!("{:?}", flags); println!("---...
2022-01-02T17:22:14Z
1.3
bitflags/bitflags
266
bitflags__bitflags-266
[ "265" ]
1aa25e1b3baf35d3d3840f12fe7e8b55adc0164a
diff --git a/src/lib.rs b/src/lib.rs index 617afea0..a4ca8429 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -500,7 +500,7 @@ macro_rules! __impl_bitflags { if first { f.write_str("(empty)")?; } - Ok(()) + $crate::_core::fmt::Result::Ok((...
diff --git a/tests/compile-pass/redefinition/result.rs b/tests/compile-pass/redefinition/result.rs new file mode 100644 index 00000000..fe915d47 --- /dev/null +++ b/tests/compile-pass/redefinition/result.rs @@ -0,0 +1,15 @@ +use bitflags::bitflags; + +// Checks for possible errors caused by overriding names used by `bi...
The bitflags macro is not sanitary wrt. standard library types and enumerations The `bitflags` macro, expanded in the prescence of a definition of the type/value `Ok` errors. Reproduction code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3fda3e36c7c6a57e0f7a83c84e56df20 Interestingly, t...
2021-12-16T09:38:14Z
1.3
bitflags/bitflags
199
bitflags__bitflags-199
[ "193" ]
dca4928b1a345b1c8b16edaf205b0f68cffd20d1
diff --git a/.travis.yml b/.travis.yml index 9dd45c47..79fdda26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ matrix: - LABEL="compiletest" script: - cargo test - - cargo test -p test_suite --features unstable + - cargo test -p test_suite - rust: stable - ...
diff --git a/test_suite/Cargo.toml b/test_suite/Cargo.toml index 2a02d80d..057a022c 100644 --- a/test_suite/Cargo.toml +++ b/test_suite/Cargo.toml @@ -2,12 +2,9 @@ name = "test_suite" version = "0.0.0" -[features] -unstable = ["compiletest_rs"] - [dependencies] bitflags = { path = "../" } -compiletest_rs = { vers...
Ensure compile tests are running In #192 I tweaked our config to work around a build error in `compiletest_rs` (there's an open PR https://github.com/laumann/compiletest-rs/pull/187 that should fix it up). We could also consider migrating to something like [`libtest_mimic`](https://crates.io/crates/libtest-mimic), whic...
We could also look at `trybuild` for this, which is nice and modern.
2019-11-01T08:52:06Z
1.2
bitflags/bitflags
127
bitflags__bitflags-127
[ "68" ]
862582d107bb74ce4c7b505b2490eb815bc3a8c2
diff --git a/.gitignore b/.gitignore index 4fffb2f8..a9d37c56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target -/Cargo.lock +target +Cargo.lock diff --git a/.travis.yml b/.travis.yml index 5ada0712..d0de6756 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ os: - linux - osx language: r...
diff --git a/compiletest/Cargo.toml b/compiletest/Cargo.toml deleted file mode 100644 index d0718acd..00000000 --- a/compiletest/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -name = "bitflags-compiletest" -version = "0.0.0" - -[dev-dependencies] -bitflags = { path = "../" } -compiletest_rs = { version = "0.2" } ...
Create a test suite crate #61 adds an `unstable_testing` feature that is only considered by tests. It seems unfortunate to leak this into the public API. Having a separate crate for tests ([like in Serde](https://github.com/serde-rs/serde/tree/master/test_suite)) would avoid this.
2017-10-17T16:27:59Z
1.0
bitflags/bitflags
125
bitflags__bitflags-125
[ "108" ]
29e60b23708123121a540fa9bde3254260952511
diff --git a/Cargo.toml b/Cargo.toml index 2686b9d2..750242aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,5 +28,8 @@ example_generated = [] [dev-dependencies] # Trick Cargo into testing this crate when we run `cargo test --all`. bitflags-compiletest = { path = "compiletest" } +serde = "1.0" +serde_derive = "1.0"...
diff --git a/tests/serde.rs b/tests/serde.rs new file mode 100644 index 00000000..0424af5f --- /dev/null +++ b/tests/serde.rs @@ -0,0 +1,35 @@ +#[macro_use] +extern crate bitflags; + +#[macro_use] +extern crate serde_derive; +extern crate serde; +extern crate serde_json; + +bitflags! { + #[derive(Serialize, Deserial...
serde support Are there any plans to support `Serialize` and `Deserialize` for generated types? I'm writing the impls manually in my code, but this falls apart once there's a ton of `bitflags` generated types. If others are interested in such a feature, maybe I can find the time to implement it myself and submit a pull...
During the libs blitz evaluation we saw that a grand total of 8 crates have dependencies on both bitflags and Serde, so we decided not to pursue it at the time. I would welcome a PR that adds Serialize and Deserialize impls behind a cfg. Adding `#[derive(Serialize, Deserialize)]` to the struct seems to work fine, I'm n...
2017-10-11T15:27:55Z
1.0
bitflags/bitflags
87
bitflags__bitflags-87
[ "65" ]
f02742c76022f4e19a461e8c05cec7f28aac1049
diff --git a/src/lib.rs b/src/lib.rs index f9c02ecb..2c76e198 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,12 +36,12 @@ pub use core as __core; /// /// bitflags! { /// struct Flags: u32 { -/// const FLAG_A = 0b00000001, -/// const FLAG_B = 0b00000010, -/// const FLAG_C ...
diff --git a/tests/external.rs b/tests/external.rs index e92b475b..fc1c3467 100644 --- a/tests/external.rs +++ b/tests/external.rs @@ -6,12 +6,12 @@ extern crate bitflags; bitflags! { /// baz struct Flags: u32 { - const A = 0b00000001, + const A = 0b00000001; #[doc = "bar"]...
Semicolons It may be too late for such a change to make sense but typically "const" items are followed by a semicolon, not comma. Semicolon would be more consistent with lazy_static as well. ```rust bitflags! { flags Flags: u32 { const A = 0b00000001; const B = 0b00000010; } } con...
2017-03-22T16:19:50Z
0.8
bitflags/bitflags
24
bitflags__bitflags-24
[ "20", "21" ]
d0884fa853eadd800fef198d9e71c8758b292db5
diff --git a/src/example_generated.rs b/src/example_generated.rs index 05b99e8f..ee5b59b1 100644 --- a/src/example_generated.rs +++ b/src/example_generated.rs @@ -9,8 +9,8 @@ bitflags! { const FLAG_A = 0b00000001; const FLAG_B = 0b00000010; const FLAG_C = 0b00000100; - ...
diff --git a/tests/conflicting_trait_impls.rs b/tests/conflicting_trait_impls.rs index 4704dfaa..933e31c9 100644 --- a/tests/conflicting_trait_impls.rs +++ b/tests/conflicting_trait_impls.rs @@ -1,4 +1,3 @@ -#![allow(dead_code)] #![no_std] #[macro_use] diff --git a/tests/external.rs b/tests/external.rs index fc1c34...
Allow namespaced flags It would be nice to have `FlagType::FlagName` be the pattern rather than dumping the flag values into the top-level namespace. Is this possible? associated constants This crate really wants to use associated constants (see https://github.com/rust-lang/rust/pull/24921) but the tricks introduced i...
2015-11-28T01:15:59Z
0.9