Repository: bitflags/bitflags
Pull request #279 (2022-04-20 08:04:42)

Fix beta test output
cc @arturoc

It looks like I did go as far as making `TRYBUILD=overwrite` work for our custom `.beta` suffixes we use for these compiler output files 🙂 I stubbed out a `CONTRIBUTING` doc for us to collect any more of this trivia that comes up.

arturoc: great, thanks! I'll merge it into my PRs as soon as all the tests are passing
arturoc: Ah I think you need this https://github.com/bitflags/bitflags/pull/277 for the tests to pass. Somehow using derive `serde::Serialize` works in some versions but others require `serde_derive::Serialize` which works for all

Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..5883363
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,9 @@
+# Updating compile-fail test outputs
+
+`bitflags` uses the `trybuild` crate to integration test its macros. Since Rust error messages change frequently enough that `nightly` builds produce spurious failures, we only check the compiler output in `beta` builds. If you run:
+
+```
+TRYBUILD=overwrite cargo +beta test --all
+```
+
+it will run the tests and update the `trybuild` output files.


Test patch:
diff --git a/tests/compile-fail/impls/copy.stderr.beta b/tests/compile-fail/impls/copy.stderr.beta
index 0c13aa5..966f3c9 100644
--- a/tests/compile-fail/impls/copy.stderr.beta
+++ b/tests/compile-fail/impls/copy.stderr.beta
@@ -1,27 +1,27 @@
-error[E0119]: conflicting implementations of trait `std::clone::Clone` for type `Flags`
+error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `Flags`
  --> $DIR/copy.rs:3:1
   |
 3 | / bitflags! {
 4 | |     #[derive(Clone, Copy)]
-  | |              ----- first implementation here
+  | |                     ---- first implementation here
 5 | |     struct Flags: u32 {
 6 | |         const A = 0b00000001;
 7 | |     }
 8 | | }
   | |_^ conflicting implementation for `Flags`
   |
-  = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
+  = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `Flags`
+error[E0119]: conflicting implementations of trait `std::clone::Clone` for type `Flags`
  --> $DIR/copy.rs:3:1
   |
 3 | / bitflags! {
 4 | |     #[derive(Clone, Copy)]
-  | |                     ---- first implementation here
+  | |              ----- first implementation here
 5 | |     struct Flags: u32 {
 6 | |         const A = 0b00000001;
 7 | |     }
 8 | | }
   | |_^ conflicting implementation for `Flags`
   |
-  = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
+  = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/compile-fail/impls/eq.stderr.beta b/tests/compile-fail/impls/eq.stderr.beta
index 8a1a3b4..cb1d6a0 100644
--- a/tests/compile-fail/impls/eq.stderr.beta
+++ b/tests/compile-fail/impls/eq.stderr.beta
@@ -1,4 +1,4 @@
-error[E0119]: conflicting implementations of trait `std::cmp::PartialEq` for type `Flags`
+error[E0119]: conflicting implementations of trait `std::marker::StructuralPartialEq` for type `Flags`
  --> $DIR/eq.rs:3:1
   |
 3 | / bitflags! {
@@ -12,35 +12,35 @@ error[E0119]: conflicting implementations of trait `std::cmp::PartialEq` for typ
   |
   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0119]: conflicting implementations of trait `std::cmp::Eq` for type `Flags`
+error[E0119]: conflicting implementations of trait `std::cmp::PartialEq` for type `Flags`
  --> $DIR/eq.rs:3:1
   |
 3 | / bitflags! {
 4 | |     #[derive(PartialEq, Eq)]
-  | |                         -- first implementation here
+  | |              --------- first implementation here
 5 | |     struct Flags: u32 {
 6 | |         const A = 0b00000001;
 7 | |     }
 8 | | }
   | |_^ conflicting implementation for `Flags`
   |
-  = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
+  = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0119]: conflicting implementations of trait `std::marker::StructuralPartialEq` for type `Flags`
+error[E0119]: conflicting implementations of trait `std::marker::StructuralEq` for type `Flags`
  --> $DIR/eq.rs:3:1
   |
 3 | / bitflags! {
 4 | |     #[derive(PartialEq, Eq)]
-  | |              --------- first implementation here
+  | |                         -- first implementation here
 5 | |     struct Flags: u32 {
 6 | |         const A = 0b00000001;
 7 | |     }
 8 | | }
   | |_^ conflicting implementation for `Flags`
   |
-  = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
+  = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0119]: conflicting implementations of trait `std::marker::StructuralEq` for type `Flags`
+error[E0119]: conflicting implementations of trait `std::cmp::Eq` for type `Flags`
  --> $DIR/eq.rs:3:1
   |
 3 | / bitflags! {
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 78bb2a5..6fada42 100644
--- a/tests/compile-fail/non_integer_base/all_defined.stderr.beta
+++ b/tests/compile-fail/non_integer_base/all_defined.stderr.beta
@@ -11,6 +11,82 @@ error[E0308]: mismatched types
     | |_^ expected struct `MyInt`, found integer
     |
     = note: this error originates in the macro `__impl_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: try wrapping the expression in `MyInt`
+    |
+492 |                 if extra_bits != MyInt(0) {
+    |                                  ++++++ +
+
+error[E0308]: mismatched types
+   --> $DIR/all_defined.rs:115:1
+    |
+115 | / bitflags! {
+116 | |     struct Flags128: MyInt {
+117 | |         const A = MyInt(0b0000_0001u8);
+118 | |         const B = MyInt(0b0000_0010u8);
+119 | |         const C = MyInt(0b0000_0100u8);
+120 | |     }
+121 | | }
+    | |_^ expected struct `MyInt`, found integer
+    |
+    = note: this error originates in the macro `__impl_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: try wrapping the expression in `MyInt`
+    |
+536 |                 Self { bits: MyInt(0) }
+    |                              ++++++ +
+
+error[E0308]: mismatched types
+   --> $DIR/all_defined.rs:115:1
+    |
+115 | / bitflags! {
+116 | |     struct Flags128: MyInt {
+117 | |         const A = MyInt(0b0000_0001u8);
+118 | |         const B = MyInt(0b0000_0010u8);
+119 | |         const C = MyInt(0b0000_0100u8);
+120 | |     }
+121 | | }
+    | |_^ expected struct `MyInt`, found integer
+    |
+    = note: this error originates in the macro `__impl_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: try wrapping the expression in `MyInt`
+    |
+562 |                 if (bits & !Self::all().bits()) == MyInt(0) {
+    |                                                    ++++++ +
+
+error[E0308]: mismatched types
+   --> $DIR/all_defined.rs:115:1
+    |
+115 | / bitflags! {
+116 | |     struct Flags128: MyInt {
+117 | |         const A = MyInt(0b0000_0001u8);
+118 | |         const B = MyInt(0b0000_0010u8);
+119 | |         const C = MyInt(0b0000_0100u8);
+120 | |     }
+121 | | }
+    | |_^ expected struct `MyInt`, found integer
+    |
+    = note: this error originates in the macro `__impl_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: try wrapping the expression in `MyInt`
+    |
+471 |                                 if Self::$Flag.bits == MyInt(0) && self.bits != 0 {
+    |                                                        ++++++ +
+
+error[E0308]: mismatched types
+   --> $DIR/all_defined.rs:115:1
+    |
+115 | / bitflags! {
+116 | |     struct Flags128: MyInt {
+117 | |         const A = MyInt(0b0000_0001u8);
+118 | |         const B = MyInt(0b0000_0010u8);
+119 | |         const C = MyInt(0b0000_0100u8);
+120 | |     }
+121 | | }
+    | |_^ expected struct `MyInt`, found integer
+    |
+    = note: this error originates in the macro `__impl_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: try wrapping the expression in `MyInt`
+    |
+471 |                                 if Self::$Flag.bits == 0 && self.bits != MyInt(0) {
+    |                                                                          ++++++ +
 
 error[E0308]: mismatched types
    --> $DIR/all_defined.rs:115:1
@@ -25,3 +101,7 @@ error[E0308]: mismatched types
     | |_^ expected struct `MyInt`, found integer
     |
     = note: this error originates in the macro `__impl_all_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: try wrapping the expression in `MyInt`
+    |
+410 |                 const $Flag: $T = MyInt(0);
+    |                                   ++++++ +