From 557ab79579d3f613b3625a01d9efd5d78749b109 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Wed, 20 Apr 2022 18:00:53 +1000 Subject: [PATCH 1/2] update test outputs --- tests/compile-fail/impls/copy.stderr.beta | 12 +-- tests/compile-fail/impls/eq.stderr.beta | 16 ++-- .../non_integer_base/all_defined.stderr.beta | 80 +++++++++++++++++++ 3 files changed, 94 insertions(+), 14 deletions(-) diff --git a/tests/compile-fail/impls/copy.stderr.beta b/tests/compile-fail/impls/copy.stderr.beta index 0c13aa50..966f3c9a 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 8a1a3b41..cb1d6a08 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 78bb2a51..6fada425 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); + | ++++++ + From 74abeb7dd5ee00f0f38615c2ad0dbaace60afdfa Mon Sep 17 00:00:00 2001 From: KodrAus Date: Wed, 20 Apr 2022 18:03:25 +1000 Subject: [PATCH 2/2] stub out a contributing doc --- CONTRIBUTING.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..58833639 --- /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.