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

Compile error on linux arm64. #2

Open
tubzby opened this issue Dec 26, 2022 · 3 comments
Open

Compile error on linux arm64. #2

tubzby opened this issue Dec 26, 2022 · 3 comments

Comments

@tubzby
Copy link

tubzby commented Dec 26, 2022

error[E0119]: conflicting implementations of trait `std::convert::TryFrom<&[u8]>` for type `MacAddr6`
   --> /home/nv/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/advmac-1.0.3/src/lib.rs:247:9
    |
239 |         impl TryFrom<&[u8]> for $nm {
    |         --------------------------- first implementation here
...
247 |         impl TryFrom<&[core::ffi::c_char]> for $nm {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MacAddr6`
...
309 | mac_impl!(MacAddr6, 6, 12);
    | -------------------------- in this macro invocation
    |
    = note: this error originates in the macro `mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0119]: conflicting implementations of trait `std::convert::TryFrom<&[u8]>` for type `MacAddr8`
   --> /home/nv/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/advmac-1.0.3/src/lib.rs:247:9
    |
239 |         impl TryFrom<&[u8]> for $nm {
    |         --------------------------- first implementation here
...
247 |         impl TryFrom<&[core::ffi::c_char]> for $nm {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MacAddr8`
...
310 | mac_impl!(MacAddr8, 8, 16);
    | -------------------------- in this macro invocation
    |
    = note: this error originates in the macro `mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0119`.
@GamePad64
Copy link
Owner

What Rust version are you trying to compile against?

@bcecchinato
Copy link

@GamePad64 I'm also having this issue on nightly-2023-02-23. This is because core::ffi::c_char and u8 are identical on armhf target.

The c_char element is defined as this :

mod c_char_definition {
    cfg_if! {
        // These are the targets on which c_char is unsigned.
        if #[cfg(any(
            all(
                target_os = "linux",
                any(
                    target_arch = "aarch64",
                    target_arch = "arm",
                    target_arch = "hexagon",
                    target_arch = "powerpc",
                    target_arch = "powerpc64",
                    target_arch = "s390x",
                    target_arch = "riscv64",
                    target_arch = "riscv32"
                )
            ),
            all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
            all(target_os = "l4re", target_arch = "x86_64"),
            all(
                any(target_os = "freebsd", target_os = "openbsd"),
                any(
                    target_arch = "aarch64",
                    target_arch = "arm",
                    target_arch = "powerpc",
                    target_arch = "powerpc64",
                    target_arch = "riscv64"
                )
            ),
            all(
                target_os = "netbsd",
                any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc")
            ),
            all(
                target_os = "vxworks",
                any(
                    target_arch = "aarch64",
                    target_arch = "arm",
                    target_arch = "powerpc64",
                    target_arch = "powerpc"
                )
            ),
            all(target_os = "fuchsia", target_arch = "aarch64"),
            target_os = "horizon"
        ))] {
            pub type c_char = u8;
            pub type NonZero_c_char = crate::num::NonZeroU8;
        } else {
            // On every other target, c_char is signed.
            pub type c_char = i8;
            pub type NonZero_c_char = crate::num::NonZeroI8;
        }
    }
}

The solution would be to exclude the TryFrom ffi function when c_cach == u8.

@bcecchinato
Copy link

And a quick and dirty solution would be to add a "feature" to enable/disable ffi parsing if you don't want to bother with managing all different platforms.

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

No branches or pull requests

3 participants