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

Derive Debug for everything. #76

Closed
seivan opened this issue Feb 26, 2019 · 8 comments · Fixed by #223
Closed

Derive Debug for everything. #76

seivan opened this issue Feb 26, 2019 · 8 comments · Fixed by #223
Labels
good first issue Good for newcomers help required We need community help to make this happen. type: enhancement New feature or request

Comments

@seivan
Copy link
Contributor

seivan commented Feb 26, 2019

Maybe related to #72 - in which close.

I rely a lot on println and I want to be able to see the fields of various objects.
Like, I want to know which adapter is currently in use and there is no way(?) as of now.

@kvark
Copy link
Member

kvark commented Feb 26, 2019

It does indeed appear to be addressed by #72, which takes a slightly different route (serialize instead of debug). For structures with trivially derived Debug, I don't mind to have it.

@nuew
Copy link

nuew commented Mar 22, 2019

The API Guidelines do suggest that every type should implement Debug, even if it doesn't give the state of all internal fields: https://rust-lang-nursery.github.io/api-guidelines/debuggability.html

@kvark
Copy link
Member

kvark commented Mar 22, 2019

@nuew thank you, that is convincing!

@grovesNL grovesNL added type: enhancement New feature or request good first issue Good for newcomers help required We need community help to make this happen. labels Jun 5, 2019
arashikou added a commit to arashikou/wgpu that referenced this issue Jun 7, 2019
This adds `#[derive(Debug)]` to all public structs and enums possible.
This also required adding it to some private types that they
transitively depend on. However, the following types depend on types
from external crates that do not implement Debug:

* `device::Device`
* `hub::Hub`
* `swap_chain::Surface`
* `swap_chain::SwapChain`

To support these types, we would need to use either custom `Debug` impls
or something like
[Derivative](https://mcarton.github.io/rust-derivative/).

This helps improve the situation in gfx-rs#76.
arashikou added a commit to arashikou/wgpu that referenced this issue Jun 7, 2019
This adds #[derive(Debug)] to all public structs and enums possible.
This also required adding it to some private types that they
transitively depend on. However, the following types depend on types
from external crates that do not implement Debug:

* device::Device
* hub::Hub
* swap_chain::Surface
* swap_chain::SwapChain

To support these types, we would need to use either custom Debug impls
or something like Derivative.

This helps improve the situation in gfx-rs#76.
bors bot added a commit that referenced this issue Jun 7, 2019
216: Add Naïve Debug Derives Where Possible r=kvark a=arashikou

This adds `#[derive(Debug)]` to all public structs and enums possible. This also required adding it to some private types that they transitively depend on. However, the following types depend on types from external crates that do not implement Debug:

* `device::Device`
* `hub::Hub`
* `swap_chain::Surface`
* `swap_chain::SwapChain`

To support these types, we would need to use either custom `Debug` impls or something like [Derivative](https://mcarton.github.io/rust-derivative/).

This helps improve the situation in #76.

Co-authored-by: John W. Bruce <arashikou@gmail.com>
bors bot added a commit that referenced this issue Jun 7, 2019
216: Add Naïve Debug Derives Where Possible r=kvark a=arashikou

This adds `#[derive(Debug)]` to all public structs and enums possible. This also required adding it to some private types that they transitively depend on. However, the following types depend on types from external crates that do not implement Debug:

* `device::Device`
* `hub::Hub`
* `swap_chain::Surface`
* `swap_chain::SwapChain`

To support these types, we would need to use either custom `Debug` impls or something like [Derivative](https://mcarton.github.io/rust-derivative/).

This helps improve the situation in #76.

Co-authored-by: John W. Bruce <arashikou@gmail.com>
arashikou added a commit to arashikou/wgpu that referenced this issue Jun 9, 2019
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.
@arashikou
Copy link
Contributor

Most of the public types now #[derive(Debug)]. (#216) There are a few exceptions, due to types that transitively depend on types from external crates that do not implement Debug. The plan (#218) is to submit PRs to get those types to implement Debug so we can in turn #[derive(Debug)] on wgpu's remaining types.

@arashikou
Copy link
Contributor

Great news! It looks like @BourgondAries already did most of this work about a week ago in gfx-rs/gfx@b576335 and gfx-rs/gfx@5e9803d. So many of our types can just derive Debug once gfx-rs does another release and wgpu picks it up.

The backend instances are the sole exceptions. I'll continue tracking through the type chains to see how best to enable them to implement Debug.

@kvark
Copy link
Member

kvark commented Jun 11, 2019

@arashikou here we come - gfx-rs/gfx#2817

@kvark
Copy link
Member

kvark commented Jun 11, 2019

@arashikou could you update to https://crates.io/crates/gfx-hal/0.2.1 and see if adding Debug here becomes trivial?

arashikou added a commit to arashikou/wgpu that referenced this issue Jun 11, 2019
With gfx-hal 0.2.1, all of the gfx-hal types that wgpu depends on
implement Debug. Thus, some types that could not derive Debug in gfx-rs#216
can now derive Debug.

The sole public type that does not derive Debug at this point is
wgpu-native::hub::Hub. It depends on backend types that do not yet
implement Debug.

Related to gfx-rs#76.
@arashikou
Copy link
Contributor

For most types, yes. Hub still depends on some types in the backends that aren't covered by @BourgondAries's changes, which I'm working on making implement Debug.

@arashikou arashikou mentioned this issue Jun 12, 2019
4 tasks
bors bot added a commit to gfx-rs/gfx that referenced this issue Jun 26, 2019
2869: Derive Debug for All Backend Instances r=kvark a=arashikou

Fixing gfx-rs/wgpu#76 is blocked on the `Instance` types for all the backends not implementing `Debug`. This patch adds `#[derive(Debug)]` to all the instances.

PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [x] tested examples with the following backends: dx11, dx12, vulkan
- [x] `rustfmt` run on changed code


Co-authored-by: John W. Bruce <juce@google.com>
bors bot added a commit to gfx-rs/gfx that referenced this issue Jun 28, 2019
2876: Derive Debug for All Backend Instances r=kvark a=arashikou

This is a backport of #2869 to the hal-0.2 branch. There are no changes to Vulkan because its `Instance` already derives `Debug`. None of the OpenGL backend changes found in the master branch version are included because the OpenGL backend does not provide `Instance` on the hal-0.2 branch.

I have verified that this branch with this commit can be used in wgpu to enable fixing gfx-rs/wgpu#76.

PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends: dx11, dx12, vulkan
- [x] `rustfmt` run on changed code


Co-authored-by: John W. Bruce <juce@google.com>
bors bot added a commit that referenced this issue Jun 29, 2019
223: Derive Debug for All Remaining Public Types r=kvark a=arashikou

With gfx-hal 0.2.1 and the various backend releases on 2019-06-28, all of the gfx-hal types that wgpu depends on implement `Debug`. Thus, some types that could not derive `Debug` in #216 can now derive `Debug`.

This patch also adds `Debug` implementations for a few types that were recently added to wgpu.

Fixes #76.

Co-authored-by: John W. Bruce <arashikou@gmail.com>
arashikou added a commit to arashikou/wgpu that referenced this issue Jun 30, 2019
With gfx-hal 0.2.1 and the various backend releases on 2019-06-28, all
of the gfx-hal types that wgpu depends on implement Debug. Thus, some
types that could not derive Debug in gfx-rs#216 can now derive Debug.

This patch also adds Debug implementations for a few types that were
recently added to wgpu.

Fixes gfx-rs#76.
arashikou added a commit to arashikou/wgpu that referenced this issue Jun 30, 2019
With gfx-hal 0.2.1, all of the gfx-hal types that wgpu depends on
implement Debug. Thus, some types that could not derive Debug in gfx-rs#216
can now derive Debug.

The sole public type that does not derive Debug at this point is
wgpu-native::hub::Hub. It depends on backend types that do not yet
implement Debug.

Related to gfx-rs#76.
arashikou added a commit to arashikou/wgpu that referenced this issue Jul 5, 2019
With gfx-hal 0.2.1 and the various backend releases on 2019-06-28, all
of the gfx-hal types that wgpu depends on implement Debug. Thus, some
types that could not derive Debug in gfx-rs#216 can now derive Debug.

This patch also adds Debug implementations for a few types that were
recently added to wgpu.

Fixes gfx-rs#76.
bors bot added a commit that referenced this issue Jul 5, 2019
223: Derive Debug for All Remaining Public Types r=kvark a=arashikou

With gfx-hal 0.2.1 and the various backend releases on 2019-06-28, all of the gfx-hal types that wgpu depends on implement `Debug`. Thus, some types that could not derive `Debug` in #216 can now derive `Debug`.

This patch also adds `Debug` implementations for a few types that were recently added to wgpu.

Fixes #76.

Co-authored-by: John W. Bruce <arashikou@gmail.com>
@bors bors bot closed this as completed in #223 Jul 5, 2019
kyren pushed a commit to kyren/wgpu that referenced this issue Oct 22, 2019
With gfx-hal 0.2.1 and the various backend releases on 2019-06-28, all
of the gfx-hal types that wgpu depends on implement Debug. Thus, some
types that could not derive Debug in gfx-rs#216 can now derive Debug.

This patch also adds Debug implementations for a few types that were
recently added to wgpu.

Fixes gfx-rs#76.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help required We need community help to make this happen. type: enhancement New feature or request
Projects
None yet
5 participants