Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails when using the -Z build-std option #46

Closed
mikeleany opened this issue Apr 12, 2021 · 2 comments
Closed

Compilation fails when using the -Z build-std option #46

mikeleany opened this issue Apr 12, 2021 · 2 comments

Comments

@mikeleany
Copy link

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.

@cuviper
Copy link
Member

cuviper commented Apr 13, 2021

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: cuviper/autocfg#34

If you enable the cargo-level i128 feature of num-traits, that should bypass autocfg detection.

@mikeleany
Copy link
Author

OK. That makes sense. Adding the i128 feature on num-traits does indeed resolve the issue.

@mikeleany mikeleany changed the title Compilation fails when i128 and u128 aren't supported Compilation fails when using the -Z build-std option Apr 14, 2021
@cuviper cuviper closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants