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

windows-bindgen: derive Eq incorrectly emitted for struct containing IReference to struct containing float #3220

Closed
mattico opened this issue Aug 25, 2024 · 3 comments · Fixed by #3255
Labels
bug Something isn't working

Comments

@mattico
Copy link

mattico commented Aug 25, 2024

Summary

See the IDL below. windows-bindgen should avoid deriving Eq for struct { IReference<StructWithF32> } similar to how it avoids it for struct { StructWithF32 }.

Crate manifest

[package]
name = "test-windows-bindgen"
version = "0.1.0"
edition = "2021"

[dependencies]
windows = { version = "0.58.0", features = ["Foundation"] }
windows-core = "0.58.0"

[build-dependencies]
windows-bindgen = "0.58.0"

Crate code

https://github.com/mattico/test-windows-bindgen

src/test.idl:

namespace Test
{
    struct StructWithF32
    {
        Single Value;
    };

    struct IReferenceStructWrapper
    {
        Windows.Foundation.IReference<StructWithF32> Value;
    };
}

src/bindings.rs:

// ...
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IReferenceStructWrapper {
    pub Value: Option<windows::Foundation::IReference<StructWithF32>>,
}
// ...
   Compiling test-windows-bindgen v0.1.0 (C:\Users\matt\Code\test-windows-bindgen)
error[E0277]: the trait bound `StructWithF32: std::cmp::Eq` is not satisfied
   --> src\bindings.rs:339:5
    |
337 | #[derive(Clone, Debug, Eq, PartialEq)]
    |                        -- in this derive macro expansion
338 | pub struct IReferenceStructWrapper {
339 |     pub Value: Option<windows::Foundation::IReference<StructWithF32>>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `StructWithF32`, which is required by `Option<IReference<StructWithF32>>: std::cmp::Eq`
    |
    = help: the trait `std::cmp::Eq` is implemented for `Option<T>`
    = note: required for `IReference<StructWithF32>` to implement `std::cmp::Eq`
    = note: 1 redundant requirement hidden
    = note: required for `Option<IReference<StructWithF32>>` to implement `std::cmp::Eq`
@mattico mattico added the bug Something isn't working label Aug 25, 2024
@kennykerr
Copy link
Collaborator

Good catch - I need to fix that.

@kennykerr
Copy link
Collaborator

Sorry for the delay - here's the fix: #3255

@mattico
Copy link
Author

mattico commented Sep 5, 2024

@kennykerr au contraire, thanks for the speedy fix! I'll test this out shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants