Page MenuHomePhabricator

Use cfg_attr(test, ...) to derive PartialEq, since this trait is only used in tests
Open, MediumPublic

Description

Description

In rust/src/lib.rs, several structs derive PartialEq, but this trait is only used in tests.

We should be able to make this derivation conditional, with

#[cfg_attr(test, derive(PartialEq))]

However, because our tests are in a separate tests directory, cfg(test) isn't recognized during compilation. We should reorganize our directory structure in order to make cfg_attr work properly.

Desired behavior/Acceptance criteria (returned value, expected error, performance expectations, etc.)

  • structs don't derive a trait in production code that is only used in test code

Completion checklist