(not serious) Why are computers so dumb

Bad day?

I've got decades of professional Software Engineering experience, and a BSc (Hons) in Software Engineering, and I wasted 7 hours on the following error when running cargo fix --allow-dirty --all --features:

   Compiling analytocs-api-v1 v0.1.0 (/Users/coliny/Dev/pride-and-joy-v2.0/pride-and-joy/crates/analytocs-api-v1)
error[E0277]: the trait bound `Stacking: Arbitrary<'_>` is not satisfied
--> crates/analytocs-api-v1/src/lib.rs:4:49
  |
4 | #[cfg_attr(any(feature = "tests", test), derive(arbitrary::Arbitrary))]
  |                                                 ^^^^^^^^^^^^^^^^^^^^ the trait `Arbitrary<'_>` is not implemented for `Stacking`
  |
  = help: the following other types implement trait `Arbitrary<'a>`:
<bool as Arbitrary<'a>>
<char as Arbitrary<'a>>
<isize as Arbitrary<'a>>
<i8 as Arbitrary<'a>>
<i16 as Arbitrary<'a>>
<i32 as Arbitrary<'a>>
<i64 as Arbitrary<'a>>
<i128 as Arbitrary<'a>>
          and 93 others
  = note: this error originates in the derive macro `arbitrary::Arbitrary` (in Nightly builds, run with -Z macro-backtrace for more info)

caused by

#[cfg_attr(any(feature = "tests", test), derive(arbitrary::Arbitrary))]
pub enum Group {
    A(Stacking),
}

#[cfg_attr(any(features = "tests", test), derive(arbitrary::Arbitrary))]
pub enum Stacking {
    A,
} 

Spot it yet? Sigh.

Spoilers: The cfg_attr on Stacking is using the misspelled features rather than feature

3 Likes

Unfortunately, clippy::maybe_misused_cfg doesn't work in this nested case.

1 Like

even with the newest AI technologies, last time I checked, computers still can't read users' mind. sigh.

3 Likes

Oh, that’s brutal… maybe either cargo or rustc (or the two together) should somehow warn about conditional compilation keys that look like misspellings of feature? In this case, edit distance is only 1, anyways. I’d suggest opening an issue if it doesn’t exist already.

5 Likes

There is an unstable feature to lint any unknown conditional compilation key. (-Zcheck-cfg) Rustc and the standard library are compiled with it enabled.

10 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.