Skip to content

Commit

Permalink
Spell out the type of the result from map_pass_err.
Browse files Browse the repository at this point in the history
Without these changes, rust-analyzer cannot determine the type of
`cmd_buf`.
  • Loading branch information
jimblandy committed May 14, 2022
1 parent 8e5ac75 commit 284ed46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (device_guard, mut token) = hub.devices.read(&mut token);

let (mut cmd_buf_guard, mut token) = hub.command_buffers.write(&mut token);
let cmd_buf = CommandBuffer::get_encoder_mut(&mut *cmd_buf_guard, encoder_id)
.map_pass_err(init_scope)?;
// Spell out the type, to placate rust-analyzer.
// https://github.com/rust-lang/rust-analyzer/issues/12247
let cmd_buf: &mut CommandBuffer<A> =
CommandBuffer::get_encoder_mut(&mut *cmd_buf_guard, encoder_id)
.map_pass_err(init_scope)?;
// will be reset to true if recording is done without errors
cmd_buf.status = CommandEncoderStatus::Error;
let raw = cmd_buf.encoder.open();
Expand Down
7 changes: 5 additions & 2 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (trackers, query_reset_state, pending_discard_init_fixups) = {
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);

let cmd_buf = CommandBuffer::get_encoder_mut(&mut *cmb_guard, encoder_id)
.map_pass_err(init_scope)?;
// Spell out the type, to placate rust-analyzer.
// https://github.com/rust-lang/rust-analyzer/issues/12247
let cmd_buf: &mut CommandBuffer<A> =
CommandBuffer::get_encoder_mut(&mut *cmb_guard, encoder_id)
.map_pass_err(init_scope)?;
// close everything while the new command encoder is filled
cmd_buf.encoder.close();
// will be reset to true if recording is done without errors
Expand Down

0 comments on commit 284ed46

Please sign in to comment.