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

Many types now missing Debug implementations in v0.29 #1392

Closed
qdot opened this issue Dec 19, 2021 · 6 comments · Fixed by #1395
Closed

Many types now missing Debug implementations in v0.29 #1392

qdot opened this issue Dec 19, 2021 · 6 comments · Fixed by #1395
Labels
enhancement New feature or request

Comments

@qdot
Copy link

qdot commented Dec 19, 2021

Similar to #1391, tried to compile https://github.com/deviceplug/btleplug with no changes, got a bunch of places where we expect Debug implementations that are now missing with no code changes other than updating from v0.28.

error[E0277]: `GattCommunicationStatus` doesn't implement `std::fmt::Debug`
  --> src\winrtble\ble\characteristic.rs:69:67
   |
69 |                 format!("Windows UWP threw error on write: {:?}", result).into(),
   |                                                                   ^^^^^^ `GattCommunicationStatus` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
   |
   = help: the trait `std::fmt::Debug` is not implemented for `GattCommunicationStatus`
   = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `GattReadResult` doesn't implement `std::fmt::Debug`
  --> src\winrtble\ble\characteristic.rs:88:66
   |
88 |                 format!("Windows UWP threw error on read: {:?}", result).into(),
   |                                                                  ^^^^^^ `GattReadResult` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
   |
   = help: the trait `std::fmt::Debug` is not implemented for `GattReadResult`
   = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `BluetoothConnectionStatus` doesn't implement `std::fmt::Debug`
  --> src\winrtble\ble\device.rs:47:42
   |
47 |                     trace!("state {:?}", sender.ConnectionStatus());
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^ `BluetoothConnectionStatus` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
   |
   = help: the trait `std::fmt::Debug` is not implemented for `BluetoothConnectionStatus`
   = note: this error originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
@qdot
Copy link
Author

qdot commented Dec 19, 2021

Ok I just saw in the v0.29 Changelog that Debug is no longer implemented by default in the new generator. Is there a flag to turn that back on somehow if needed?

@kennykerr
Copy link
Collaborator

Yes, the Debug trait is not provided by the new bindgen crate. Is that something that I should preserve? I'm trimmed it down to the basics as far as traits go as it all adds up to the expense of building with the windows crate but it would help to understand whether this is something that is just a convenience or is really needed.

@poliorcetics
Copy link
Contributor

Deriving Debug on pretty much everything is something we do by default internally, it would be really nice to have it for windows types, manually implementing it is cumbersome.

@roblabla
Copy link
Contributor

IMO, Debug should really be implemented on everything. It is part of the Rust API Guidelines: https://rust-lang.github.io/api-guidelines/debuggability.html?highlight=debug#all-public-types-implement-debug-c-debug and are a huge help when debugging issues, as they allow quickly printing the contents of a structure. The problem with not implementing debug is that it causes a cascade of problems: Structures containing windows-rs structs will themselves not be able to derive debug, neither will their parent structures, etc... This makes working with crates that don't implement debug incredibly painful.

I really hope that this is reverted, or at least that a compile-time option to enable Debug is provided.

@kennykerr
Copy link
Collaborator

Good feedback. Much appreciated.

@qdot
Copy link
Author

qdot commented Dec 23, 2021

Thanks for being so responsive on this! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants