gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 549 forks source link

Use thiserror and refactor errors #3496

Closed kvark closed 3 years ago

kvark commented 3 years ago

Makes error variants a bit more sane and structured. Also takes advantage of thiserror, since that's what we settled on in wgpu land. PR checklist:

New code (HAL only):

Finished dev [unoptimized + debuginfo] target(s) in 17.65s

Old code (HAL only):

Finished dev [unoptimized + debuginfo] target(s) in 7.73s

kvark commented 3 years ago

New timing - cargo-timing-20201202T054953Z.html.zip Old timing - cargo-timing-20201202T055308Z.html.zip

It's clear that gfx itself doesn't take more time to build. In fact, even less. But in total the time now has to include the thiserror dependencies, including syn, quote, and proc-macro.

So it's a question of whether we expect the clients to already depend on thiserror (in which case it's free), or not. The benefit is clear - our code becomes more manageable (+338 −865).

kvark commented 3 years ago

I believe the most important (current and future) consumers of gfx-hal are:

So I think we should bite the bullet and go for it.

grovesNL commented 3 years ago

bors r+

bors[bot] commented 3 years ago

Build succeeded: