gfx-rs / portability

Vulkan Portability Implementation
Mozilla Public License 2.0
383 stars 25 forks source link

Fix rustc warnings #204

Closed krolli closed 4 years ago

krolli commented 4 years ago

This PR fixes warnings encountered with stable 1.40.0 rust toolchain. The most interesting issue is likely switch from mem::zeroed() and related functions to MaybeUninit.

While mem::zeroed() is not marked deprecated in the same way as mem::uninitialized() is, compiler still threw warning on it. However, in this case it may have been causing undefined behavior, as EntryPoint contains references which may not be null. Another option here would be using Option instead of MaybeUninit, which would be completely safe with some extra checks. Since original code didn't, and because valid Vulkan use requires exactly one vertex shader, I chose to use MaybeUninit instead.

kvark commented 4 years ago

Still something is failing?

grovesNL commented 4 years ago

From Metal CI:

error[E0594]: cannot assign to `swapchain.acquire_mode`, as `swapchain` is not declared as mutable

    --> libportability-gfx/src/impls.rs:4475:13

     |

4450 |       let (swapchain, backbuffers) = match unsafe {

     |            --------- help: consider changing this to be mutable: `mut swapchain`

...

4475 | /             swapchain.acquire_mode = match value.to_lowercase().as_str() {

4476 | |                 "wait" => AcquireMode::Wait,

4477 | |                 "oldest" => AcquireMode::Oldest,

4478 | |                 other => panic!("unknown acquiring option: {}", other),

4479 | |             };

     | |_____________^ cannot assign

error: aborting due to previous error
krolli commented 4 years ago

Lesson learned. I'll have to set up Travis for my fork to catch these before making pull requests...

kvark commented 4 years ago

Please squash the commits

kvark commented 4 years ago

I'll have to set up Travis for my fork to catch these before making pull requests...

No need for that. Testing your PR errors here is totally fine, at least as long as it compiles at least on your machine. If we required the contributors to test on all platforms before making a PR, we'd not get too far :)

krolli commented 4 years ago

Fixed and squashed.

kvark commented 4 years ago

Bors r+

On Jan 23, 2020, at 01:30, Martin Krošlák notifications@github.com wrote:

 Fixed and squashed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

bors[bot] commented 4 years ago

Build succeeded