As of Rust 1.84, cargo will check every feature referenced by #[cfg()] /#[cfg_attr()] to ensure that they refer to actual features of the current crate. This leads to warnings when using uom's quantity! and system! macros.
Given this code, using uom = 0.36.0:
#[macro_use]
extern crate uom;
pub mod time {
quantity! {
quantity: Time; "time";
dimension: Q<P1>;
units {
@second: 1.0; "s", "second", "seconds";
}
}
}
system! {
quantities: Q {
time: second, T;
}
units: U {
mod time::Time,
}
}
I get the following warnings when running cargo check:
warning: unexpected `cfg` condition value: `si`
--> src/lib.rs:14:1
|
14 | / system! {
15 | | quantities: Q {
16 | | time: second, T;
17 | | }
... |
21 | | }
22 | | }
| |_^
|
= note: no expected values for `feature`
= help: consider adding `si` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
= note: this warning originates in the macro `system` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unexpected `cfg` condition value: `f32`
--> src/lib.rs:14:1
|
14 | / system! {
15 | | quantities: Q {
16 | | time: second, T;
17 | | }
... |
21 | | }
22 | | }
| |_^
|
= note: no expected values for `feature`
= help: consider adding `f32` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: this warning originates in the macro `system` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unexpected `cfg` condition value: `si`
--> src/lib.rs:14:1
|
14 | / system! {
15 | | quantities: Q {
16 | | time: second, T;
17 | | }
... |
21 | | }
22 | | }
| |_^
|
= note: no expected values for `feature`
= help: consider adding `si` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: this warning originates in the macro `system` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unexpected `cfg` condition value: `si`
--> src/lib.rs:5:5
|
5 | / quantity! {
6 | | quantity: Time; "time";
7 | | dimension: Q<P1>;
8 | | units {
9 | | @second: 1.0; "s", "second", "seconds";
10 | | }
11 | | }
| |_____^
|
= note: no expected values for `feature`
= help: consider adding `si` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: this warning originates in the macro `quantity` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unexpected `cfg` condition value: `f32`
--> src/lib.rs:5:5
|
5 | / quantity! {
6 | | quantity: Time; "time";
7 | | dimension: Q<P1>;
8 | | units {
9 | | @second: 1.0; "s", "second", "seconds";
10 | | }
11 | | }
| |_____^
|
= note: no expected values for `feature`
= help: consider adding `f32` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: this warning originates in the macro `quantity` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unexpected `cfg` condition value: `cargo-clippy`
--> src/lib.rs:14:1
|
14 | / system! {
15 | | quantities: Q {
16 | | time: second, T;
17 | | }
... |
21 | | }
22 | | }
| |_^
|
= note: no expected values for `feature`
= help: consider adding `cargo-clippy` as a feature in `Cargo.toml`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: this warning originates in the macro `system` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: `uom-warning` (lib) generated 70 warnings (64 duplicates)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
Expanding the quantity macro, it looks like this is being triggered by lines like the following:
#[cfg_attr(all(feature = "si", feature = "f32"), doc = " ```rust")]
#[cfg_attr(not(all(feature = "si", feature = "f32")), doc = " ```rust,ignore")]
It looks like what's happening is that those macros are assuming they're going to be used in the context of the uom crate, so they refer to uom features. But when they're used and expanded as part of another crate, it tries to find si and f32 features in the current crate, and flags them as not existing.
Expanding the system macro, the warnings on the missing cargo-clippy feature are caused by things like this:
#[cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))]
pub fn is_sign_positive(self) -> bool
This looks relevant: https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html
The easiest workaround is to add #![expect(unexpected_cfgs)] at the top of the module that makes use of the uom macros.
I've also written a minimal repro of this in this repo, you can trigger the warnings by checking that repo out and running cargo check.
As of Rust 1.84,
cargowill check every feature referenced by#[cfg()]/#[cfg_attr()]to ensure that they refer to actual features of the current crate. This leads to warnings when usinguom'squantity!andsystem!macros.Given this code, using
uom = 0.36.0:I get the following warnings when running
cargo check:Expanding the
quantitymacro, it looks like this is being triggered by lines like the following:It looks like what's happening is that those macros are assuming they're going to be used in the context of the
uomcrate, so they refer touomfeatures. But when they're used and expanded as part of another crate, it tries to findsiandf32features in the current crate, and flags them as not existing.Expanding the
systemmacro, the warnings on the missingcargo-clippyfeature are caused by things like this:This looks relevant: https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html
The easiest workaround is to add
#![expect(unexpected_cfgs)]at the top of the module that makes use of the uom macros.I've also written a minimal repro of this in this repo, you can trigger the warnings by checking that repo out and running
cargo check.