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

No option to disable derive(Debug) #432

Closed
jethrogb opened this issue Jan 24, 2017 · 5 comments
Closed

No option to disable derive(Debug) #432

jethrogb opened this issue Jan 24, 2017 · 5 comments

Comments

@jethrogb
Copy link
Contributor

Once #429 is fixed, it's once again possible to have types in your Rust structs that don't implement Debug. Therefore, deriving Debug is not possible for such types. bindgen 0.19 had a derive_debug option to turn off generating Debug.

@emilio
Copy link
Contributor

emilio commented Jan 24, 2017

This one is easy to support if there's a good use case for it, and this one seems like a decent one.

This is really easy to add. I'm digging in other problems now, but will do it.

@dimbleby
Copy link
Contributor

Overlaps second bullet of #424

emilio added a commit to emilio/rust-bindgen that referenced this issue Jan 24, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Jan 24, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Jan 24, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Jan 24, 2017
bors-servo pushed a commit that referenced this issue Jan 24, 2017
Honor and expose the derive_debug option.

Fixes #432

r? @fitzgen
emilio added a commit to emilio/rust-bindgen that referenced this issue Jan 24, 2017
bors-servo pushed a commit that referenced this issue Jan 24, 2017
Honor and expose the derive_debug option.

Fixes #432

r? @fitzgen
@andreeaflorescu
Copy link

It seems like derive debug is also added to packed structures. This generates the following warning on build:

warning: #[derive] can't be used on a #[repr(packed)] struct that does not derive Copy (error E0133)                                                                                                                                                                               
   --> virtio_gen/src/virtio_net.rs:684:10                                                                                                                                                                                                                                         
    |                                                                                                                                                                                                                                                                              
684 | #[derive(Debug, Default)]                                                                                                                                                                                                                                                    
    |          ^^^^^                                                                                                                                                                                                                                                               
    |                                                                                                                                                                                                                                                                              
    = note: #[warn(safe_packed_borrows)] on by default                                                                                                                                                                                                                             
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!                                                                                                                                              
    = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>                                                                                                                                                                                                                                                                                 

The structure that is causing the previous error:

#[repr(C, packed)]
#[derive(Debug, Default)]
pub struct virtio_net_ctrl_mac {
    pub entries: __virtio32,
    pub macs: __IncompleteArrayField<[__u8; 6usize]>,
}

Our workaround right now is to manually remove the debug derive, but it would be nice to have an argument like --no-derive-debug=virtio_net_ctrl_mac.

@emilio
Copy link
Contributor

emilio commented Jan 15, 2019

Can you file a new issue for that? It's hard to keep track of comments in closed issues. IIUC what you want is an option to individually control #[derive(Debug)] per struct and such, right?

@andreeaflorescu
Copy link

Yap, that is exactly what I was thinking about. I'll open a new issue.

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