Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoids skipping getter in MessageSessionId when testing.
Recently, the getters for the priority field in `uavcan::session_id::message::MessageSessionId` were disabled from being generated to avoid an unused warning, as they are, indeed, unused in the build codebase. Nonetheless, the getter for `priority` is actually used by one of the tests, such that is needed, but only when testing. The general way to do this, would be to add a `#[cfg_attr(...)]` for the `skip` attribute to avoid generating it during testing. Unfortunately, `cfg*` attributes are not expanded before `proc_macro_attributes` expansion and the `modular-bitfield` does not manage them manually. This is a general problem in the proc-macro environment, with an example being taiki-e/pin-project#68. The rust team is working on a solution to this, see, for example: https://doc.rust-lang.org/beta/unstable-book/library-features/cfg-eval.html https://doc.rust-lang.org/beta/unstable-book/language-features/macro-attributes-in-derive-output.html And the related issues. In particular, `cfg_eval` provides a way to ensure that the `cfg` attributes are evaluated before the expansion of the following macros. For this reason, the `cfg_eval` was activated, a `#[cfg_eval]` attribute was added to `MessageSessionId` and a `cfg_attr` conditioned on `test` was added to the priority field of the same structure. As this is not yet stabilized, the crate now depends on nightly, and cannot be compiled in stable. It was possible to provide workarounds to avoid moving outside stable. For example, by duplicating `MessageSessionsId` and providing a version with the `skip` attribute and one without, conditioning the whole structure, instead of a field attribute, on `test`. Nonetheless, being nightly only is not considered a problem for this crate usage and the "forward-correct" solution was thus preferred.
- Loading branch information