repo stringclasses 1
value | problem_statement stringclasses 9
values | hints_text stringclasses 4
values | instance_id stringclasses 9
values | issue_numbers sequencelengths 1 1 | base_commit stringclasses 8
values | test_patch stringclasses 9
values | version stringclasses 6
values | pull_number int64 211 355 | created_at stringclasses 9
values | patch stringclasses 9
values | environment_setup_commit stringclasses 6
values | FAIL_TO_PASS sequencelengths 1 2 | PASS_TO_PASS sequencelengths 42 95 | FAIL_TO_FAIL sequencelengths 0 1 | PASS_TO_FAIL sequencelengths 0 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bitflags/bitflags | 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... | bitflags__bitflags-355 | [
"357"
] | 31d3e4afefc964045156d7fe3622733f48511353 | diff --git a/tests/compile-fail/bitflags_custom_bits.rs b/tests/compile-fail/bitflags_custom_bits.rs
--- 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::{ParseError, FromHex}};
+use bitflags:... | 2.3 | 355 | 2023-05-17T11:22:15Z | diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
--- 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
+ runs-on: ubuntu-latest
+ steps:
... | 09f71f492d0f76d63cd286c3869c70676297e204 | [
"tests/compile-pass/bitflags_self_in_value.rs",
"pass"
] | [
"tests::bits_types",
"tests::into_iter_from_iter_roundtrip",
"tests::submodule::test_private",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"te... | [] | [] | |
bitflags/bitflags | 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. | bitflags__bitflags-345 | [
"344"
] | cbcafa710fc31172511e62efa06ad9eb214e4734 | diff --git /dev/null b/tests/compile-pass/large.rs
new file mode 100644
--- /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 and associated
+documentation files (the "So... | 2.2 | 345 | 2023-04-24T04:29:26Z | diff --git a/src/example_generated.rs b/src/example_generated.rs
--- 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 value `0b00000001`.
A ... | cbcafa710fc31172511e62efa06ad9eb214e4734 | [
"tests/compile-pass/large.rs",
"pass"
] | [
"tests::bits_types",
"tests::submodule::test_private",
"tests::into_iter_from_iter_roundtrip",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"te... | [] | [] |
bitflags/bitflags | Display missing extra bits for multi-bit flags
See: https://github.com/bitflags/bitflags/issues/310#issuecomment-1470122112
Given a flags type with two flags, `BIT = 0b0000_0001` and `MASK = 0b0001_1110`, formatting the value `3` should result in `BIT | 0x2`, but instead it gives `BIT`. That extra bit gets lost, so ... | bitflags__bitflags-316 | [
"315"
] | ad0271116e28a79ea880334dd3d06212a224ec09 | diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1154,17 +1154,39 @@ mod tests {
#[test]
fn test_display_from_str_roundtrip() {
- fn format_parse_case(flags: FmtFlags) {
+ fn format_parse_case<T: fmt::Debug + fmt::Display + str::FromStr + PartialEq>(flags: T) where <T... | 2.0 | 316 | 2023-03-16T00:19:13Z | diff --git a/src/internal.rs b/src/internal.rs
--- a/src/internal.rs
+++ b/src/internal.rs
@@ -89,7 +89,8 @@ macro_rules! __impl_internal_bitflags {
// Iterate over the valid flags
let mut first = true;
- for (name, _) in self.iter_names() {
+ let mut it... | 11640f19a7644f3967631733f33ec87b9f911951 | [
"tests::test_display_from_str_roundtrip"
] | [
"tests::into_iter_from_iter_roundtrip",
"tests::test_assignment_operators",
"tests::submodule::test_private",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"tests::test_disjoint_inte... | [] | [] | |
bitflags/bitflags | 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... | bitflags__bitflags-281 | [
"215"
] | f38ce72d11ef3e264d4b62f360bd8a5597b916d9 | diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1353,7 +1321,10 @@ mod tests {
assert_eq!(UNION, Flags::A | Flags::C);
assert_eq!(DIFFERENCE, Flags::all() - Flags::A);
assert_eq!(COMPLEMENT, !Flags::C);
- assert_eq!(SYM_DIFFERENCE, (Flags::A | Flags::C) ^ (Fl... | 1.3 | 281 | 2022-05-03T06:59:46Z | diff --git a/src/bitflags_trait.rs b/src/bitflags_trait.rs
--- 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 {}
diff --git a/src/bitflags_trait.rs b/src... | 810dc35aba3df7314de01b93c7aa137968e925d4 | [
"tests::test_debug",
"tests::test_iter"
] | [
"tests::submodule::test_private",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_default",
"tests::test_deprecated",
"tests::test_disjoint_intersects",
"tests::test_empty_bitflags",
"tests::test_empty_doe... | [] | [] |
bitflags/bitflags | 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... | bitflags__bitflags-276 | [
"275"
] | 0141a07e55184304857384b0093d00959f0acfa6 | diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1891,6 +1907,37 @@ mod tests {
}
}
+ #[test]
+ fn test_from_bits_edge_cases() {
+ bitflags! {
+ struct Flags: u8 {
+ const A = 0b00000001;
+ const BC = 0b00000110;
+ ... | 1.3 | 276 | 2022-04-19T09:54:30Z | diff --git a/src/lib.rs b/src/lib.rs
--- 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::_core::option::Option<Self> {
- ... | 810dc35aba3df7314de01b93c7aa137968e925d4 | [
"tests::test_from_bits_edge_cases",
"tests::test_from_bits_truncate_edge_cases"
] | [
"tests::submodule::test_private",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"tests::test_disjoint_intersects",
"tests::test_empty_bitflags",
... | [
"fail"
] | [] | |
bitflags/bitflags | 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!("---... | bitflags__bitflags-268 | [
"267"
] | 1aa25e1b3baf35d3d3840f12fe7e8b55adc0164a | diff --git a/tests/compile-fail/trait/custom_impl.rs b/tests/compile-fail/trait/custom_impl.rs
--- 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 --git a/tests/compile-pass/impls/co... | 1.3 | 268 | 2022-01-02T17:22:14Z | diff --git a/src/lib.rs b/src/lib.rs
--- 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")?;
- $crate::_core::fmt::LowerHex::f... | 810dc35aba3df7314de01b93c7aa137968e925d4 | [
"tests/compile-pass/impls/fmt.rs",
"pass"
] | [
"tests::submodule::test_private",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"tests::test_disjoint_intersects",
"tests::test_empty_bitflags",
... | [
"fail"
] | [] | |
bitflags/bitflags | 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... | bitflags__bitflags-266 | [
"265"
] | 1aa25e1b3baf35d3d3840f12fe7e8b55adc0164a | diff --git /dev/null b/tests/compile-pass/redefinition/result.rs
new file mode 100644
--- /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 `bitflags!` internally.
+
+// bug #265 (https://github.com/bit... | 1.3 | 266 | 2021-12-16T09:38:14Z | diff --git a/src/lib.rs b/src/lib.rs
--- 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(())
}
}
... | 810dc35aba3df7314de01b93c7aa137968e925d4 | [
"tests/compile-pass/redefinition/result.rs",
"pass"
] | [
"tests::submodule::test_private",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"tests::test_disjoint_intersects",
"tests::test_empty_bitflags",
... | [
"fail"
] | [] | |
bitflags/bitflags | is_all() vs. from_bits_unchecked()
[`unsafe from_bits_unchecked()`](https://docs.rs/bitflags/1.2.1/bitflags/example_generated/struct.Flags.html#method.from_bits_unchecked) allows creating instances with extra bits. The caller of the `bitflags!` macro can decide if this is allowed for their type. Let's assume it is for ... | bitflags__bitflags-211 | [
"208"
] | 15e911c304d5bd8805af55d7e4f8c5324ed798ee | diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1048,6 +1048,11 @@ mod tests {
assert!(!Flags::A.is_all());
assert!(Flags::ABC.is_all());
+ let extra = unsafe { Flags::from_bits_unchecked(0b1000) };
+ assert!(!extra.is_all());
+ assert!(!(Flags::A | ex... | 1.2 | 211 | 2020-02-04T10:52:16Z | diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -664,7 +664,7 @@ macro_rules! __impl_bitflags {
/// Returns `true` if all flags are currently set.
#[inline]
pub const fn is_all(&self) -> bool {
- self.bits == $BitFlags::all(... | bd24f9d8d266bfb2dfe4b8238b196ecf5e37dee1 | [
"tests::test_is_all"
] | [
"tests::submodule::test_private",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_deprecated",
"tests::test_disjoint_intersects",
"tests::test_empty_does_not_intersect_with_full",
"tes... | [] | [] | |
bitflags/bitflags | 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... | bitflags__bitflags-341 | [
"308"
] | dc971042c8132a5381ab3e2165983ee7f9d44c63 | diff --git /dev/null b/tests/compile-pass/doc_alias.rs
new file mode 100644
--- /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(alias = "FLAG_A")]
+ const A = 1;
+ }
+}
... | 2.1 | 341 | 2023-04-18T00:36:26Z | diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -558,6 +558,315 @@ macro_rules! bitflags {
}
$($t:tt)*
+ ) => {
+ __declare_bitflags!(
+ $(#[$outer])*
+ $vis struct $BitFlags: $T {
+ $(
+ $(#[$inner $($args)*... | dc971042c8132a5381ab3e2165983ee7f9d44c63 | [
"tests/compile-pass/doc_alias.rs",
"pass"
] | [
"tests::bits_types",
"tests::submodule::test_private",
"tests::into_iter_from_iter_roundtrip",
"tests::test_assignment_operators",
"tests::test_binary",
"tests::test_bits",
"tests::test_const_fn",
"tests::test_contains",
"tests::test_debug",
"tests::test_default",
"tests::test_deprecated",
"te... | [] | [] |
README.md exists but content is empty.
- Downloads last month
- 2