Compilation fails when using the -Z build-std option
Compilation fails when i128 and u128 aren't supported. For example, when compiling a crate with these options: -Z build-std=core,alloc,compiler_builtins --target=x86_64-unknown-uefi.
error[E0407]: method `from_i128` is not a member of trait `_num_traits::FromPrimitive`
--> src/x86_64.rs:112:62
|
112 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, FromPrimitive, ToPrimitive)]
| ^^^^^^^^^^^^^ not a member of trait `_num_traits::FromPrimitive`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0407]: method `from_u128` is not a member of trait `_num_traits::FromPrimitive`
--> src/x86_64.rs:112:62
|
112 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, FromPrimitive, ToPrimitive)]
| ^^^^^^^^^^^^^ not a member of trait `_num_traits::FromPrimitive`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0407]: method `to_i128` is not a member of trait `_num_traits::ToPrimitive`
--> src/x86_64.rs:112:77
|
112 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, FromPrimitive, ToPrimitive)]
| ^^^^^^^^^^^ not a member of trait `_num_traits::ToPrimitive`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0407]: method `to_u128` is not a member of trait `_num_traits::ToPrimitive`
--> src/x86_64.rs:112:77
|
112 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, FromPrimitive, ToPrimitive)]
| ^^^^^^^^^^^ not a member of trait `_num_traits::ToPrimitive`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
Pull request #45 has been submitted to correct this issue.
i128 should be supported for all versions of rustc currently supported by num-derive, but num-traits supports older versions that might not. The real failure is that autocfg doesn't work with -Z build-std: https://github.com/cuviper/autocfg/issues/34
If you enable the cargo-level i128 feature of num-traits, that should bypass autocfg detection.
OK. That makes sense. Adding the i128 feature on num-traits does indeed resolve the issue.