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

Debug derived when not working for opaque type #1019

Closed
usamec opened this issue Sep 22, 2017 · 3 comments
Closed

Debug derived when not working for opaque type #1019

usamec opened this issue Sep 22, 2017 · 3 comments

Comments

@usamec
Copy link

usamec commented Sep 22, 2017

Input C/C++ Header

class A {
  long long b;
  long long b2;                
  long long b3;                                                                                          
  long long b4;                                                                                          
  long long b5; 
  long long b6;
  long long b7;                                                                                          
  long long b8;                                                                                          
  long long bb;                                                                                          
  long long bb2;
  long long bb3;                                                                                         
  long long bb4;
  long long bb5;
  long long bb6;                                                                                         
  long long bb7;
  long long bb8;
  long long c;                                                                                           
  long long c2;
  long long c3;                                                                                          
  long long c4;
  long long c5;                                                                                          
  long long c6;
  long long c7;                                                                                          
  long long c8;
  long long cc;                                                                                          
  long long cc2;                                                                                         
  long long cc3;                                                                                         
  long long cc4;
  long long cc5;
  long long cc6;                                                                                         
  long long cc7;                                                                                         
  long long cc8;
  long long dd2;
  long long dd3;
  long long dd4;
  long long dd5;
  long long dd6;                                                                                         
  long long dd7;                                                                                         
  long long dd8;
}; 

Bindgen Invocation

$ bindgen test_bing3.hpp -o src/bindings.rs --opaque-type "A" -- -x c++

Actual Results

#[repr(C)]
#[derive(Debug)]
pub struct A {
    pub _bindgen_opaque_blob: [u64; 39usize],
}
#[test]
fn bindgen_test_layout_A() {
    assert_eq!(::std::mem::size_of::<A>() , 312usize , concat ! (
               "Size of: " , stringify ! ( A ) ));
    assert_eq! (::std::mem::align_of::<A>() , 8usize , concat ! (
                "Alignment of " , stringify ! ( A ) ));
}

and/or

error[E0277]: the trait bound `[u64; 39]: std::fmt::Debug` is not satisfied
 --> src/bindings.rs:6:5
  |
6 |     pub _bindgen_opaque_blob: [u64; 39usize],
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[u64; 39]` cannot be formatted using `:?`; if it is defined in your crate, add `#[derive(Debug)]` or manually implement it
  |
  = help: the trait `std::fmt::Debug` is not implemented for `[u64; 39]`
  = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u64; 39]`
  = note: required for the cast to the object type `std::fmt::Debug`

Expected Results

Debug trait is not used.

@fitzgen
Copy link
Member

fitzgen commented Sep 22, 2017

What version of bindgen are you using? I thought we fixed exactly this bug in the last release, but maybe the fix is stuck on master and isn't released yet...

@pepyakin
Copy link
Contributor

Yep, it doesn't reproduce on the master,

/* automatically generated by rust-bindgen */

#[repr(C)]
pub struct A {
    pub _bindgen_opaque_blob: [u64; 39usize],
}
#[test]
fn bindgen_test_layout_A() {
    assert_eq!(
        ::std::mem::size_of::<A>(),
        312usize,
        concat!("Size of: ", stringify!(A))
    );
    assert_eq!(
        ::std::mem::align_of::<A>(),
        8usize,
        concat!("Alignment of ", stringify!(A))
    );
}

@fitzgen
Copy link
Member

fitzgen commented Sep 22, 2017

Ok, let's close this after we cut a new release.

All that is blocking that is #977

@pvdrz pvdrz closed this as completed Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants