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

Add Debug Implementations to Remaining Public Types #218

Closed
wants to merge 1 commit into from

Conversation

arashikou
Copy link
Contributor

@arashikou arashikou commented Jun 9, 2019

There were some types that could not derive Debug automatically in #216 because they (or types they transitively contained) contained types from external crates that do not implement Debug. By adding custom Debug impls, we can handle this case. The Debug impls given here do the same thing #[derive(Debug)] would do, except that they skip the fields that do not themselves implement Debug.

After this, all public types will implement Debug, as requested in #76.
Closes #76

There were some types that could not derive Debug automatically in gfx-rs#216
because they (or types they transitively contained) contained types from
external crates that do not implement Debug. By adding custom Debug
impls, we can handle this case. The Debug impls given here do the same
thing #[derive(Debug)] would do, except that they skip the fields that
do not themselves implement Debug.

After this, all public types will implement Debug, as requested in gfx-rs#76.
@@ -518,6 +527,23 @@ impl Device<back::Backend> {
}
}

impl<B: hal::Backend> fmt::Debug for Device<B> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the queue group the only thing that isn't Debug? We might want an easier way to solve this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

impl fmt::Debug for Hub {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Hub")
.field("surfaces", &self.surfaces)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is instances the only thing that isn't Debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's also adapters.

.field("device_id", &self.device_id)
.field("desc", &self.desc)
.field("acquired", &self.acquired)
.field("sem_available", &self.sem_available)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is command pool the only thing that isn't Debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's also frames.

@arashikou
Copy link
Contributor Author

In each struct, there are only one or two fields that are incompatible with Debug. Unfortunately, it's not possible to #[derive(Debug) except for this one field] in the standard library. The two alternatives that I've thought of:

  1. Submit changes to the upstream crates to implement Debug for these types, then wait for releases so we can update wgpu's types. They're public types of those crates, so they should really implement Debug anyway.
  2. Derivative contains macros that allow code to omit fields from #[derive(Debug)], but I don't know if you want to take on a dependency.

Do you have any other ideas?

@kvark
Copy link
Member

kvark commented Jun 10, 2019 via email

@arashikou
Copy link
Contributor Author

OK. I'll start tracking all these types down throughout the gfx crate family and get back to you.

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

Successfully merging this pull request may close these issues.

Derive Debug for everything.
2 participants