Skip to content

Commit 0e352f5

Browse files
Resolve lints for Rust 1.78-1.81 that can be preempted before upgrade (#6225)
* chore: remove `Context` methods detected as dead code This is detected by `rustc` as of Rust 1.79.0. * refactor: satisfy `clippy::manual_inspect` Detected as of Rust 1.81.0. * refactor: satisfy `clippy::needless_borrows_for_generic_args` Detected as of Rust 1.81.0. * refactor: suppress false-positive `dead_code` lint for `SubmissionIndex` * chore: eliminate `dead_code` when `target_os = "emscripten"`
1 parent 07684d3 commit 0e352f5

File tree

11 files changed

+46
-319
lines changed

11 files changed

+46
-319
lines changed

benches/benches/computepass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn run_bench(ctx: &mut Criterion) {
447447
};
448448

449449
group.bench_function(
450-
&format!("{cpasses} computepasses x {dispatch_per_pass} dispatches ({label})"),
450+
format!("{cpasses} computepasses x {dispatch_per_pass} dispatches ({label})"),
451451
|b| {
452452
Lazy::force(&state);
453453

@@ -496,7 +496,7 @@ fn run_bench(ctx: &mut Criterion) {
496496
for threads in [2, 4, 8] {
497497
let dispatch_per_pass = dispatch_count / threads;
498498
group.bench_function(
499-
&format!("{threads} threads x {dispatch_per_pass} dispatch"),
499+
format!("{threads} threads x {dispatch_per_pass} dispatch"),
500500
|b| {
501501
Lazy::force(&state);
502502

@@ -537,7 +537,7 @@ fn run_bench(ctx: &mut Criterion) {
537537
let mut group = ctx.benchmark_group("Computepass: Bindless");
538538
group.throughput(Throughput::Elements(dispatch_count_bindless as _));
539539

540-
group.bench_function(&format!("{dispatch_count_bindless} dispatch"), |b| {
540+
group.bench_function(format!("{dispatch_count_bindless} dispatch"), |b| {
541541
Lazy::force(&state);
542542

543543
b.iter_custom(|iters| {

benches/benches/renderpass.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ fn run_bench(ctx: &mut Criterion) {
448448
};
449449

450450
group.bench_function(
451-
&format!("{rpasses} renderpasses x {draws_per_pass} draws ({label})"),
451+
format!("{rpasses} renderpasses x {draws_per_pass} draws ({label})"),
452452
|b| {
453453
Lazy::force(&state);
454454

@@ -501,49 +501,46 @@ fn run_bench(ctx: &mut Criterion) {
501501

502502
for threads in [2, 4, 8] {
503503
let draws_per_pass = draw_count / threads;
504-
group.bench_function(
505-
&format!("{threads} threads x {draws_per_pass} draws"),
506-
|b| {
507-
Lazy::force(&state);
504+
group.bench_function(format!("{threads} threads x {draws_per_pass} draws"), |b| {
505+
Lazy::force(&state);
508506

509-
b.iter_custom(|iters| {
510-
profiling::scope!("benchmark invocation");
507+
b.iter_custom(|iters| {
508+
profiling::scope!("benchmark invocation");
511509

512-
// This benchmark hangs on Apple Paravirtualized GPUs. No idea why.
513-
if state.device_state.adapter_info.name.contains("Paravirtual") {
514-
return Duration::from_secs_f32(1.0);
515-
}
510+
// This benchmark hangs on Apple Paravirtualized GPUs. No idea why.
511+
if state.device_state.adapter_info.name.contains("Paravirtual") {
512+
return Duration::from_secs_f32(1.0);
513+
}
516514

517-
let mut duration = Duration::ZERO;
515+
let mut duration = Duration::ZERO;
518516

519-
for _ in 0..iters {
520-
profiling::scope!("benchmark iteration");
517+
for _ in 0..iters {
518+
profiling::scope!("benchmark iteration");
521519

522-
let start = Instant::now();
520+
let start = Instant::now();
523521

524-
let buffers = (0..threads)
525-
.into_par_iter()
526-
.map(|i| state.run_subpass(i, threads, draw_count))
527-
.collect::<Vec<_>>();
522+
let buffers = (0..threads)
523+
.into_par_iter()
524+
.map(|i| state.run_subpass(i, threads, draw_count))
525+
.collect::<Vec<_>>();
528526

529-
duration += start.elapsed();
527+
duration += start.elapsed();
530528

531-
state.device_state.queue.submit(buffers);
532-
state.device_state.device.poll(wgpu::Maintain::Wait);
533-
}
529+
state.device_state.queue.submit(buffers);
530+
state.device_state.device.poll(wgpu::Maintain::Wait);
531+
}
534532

535-
duration
536-
})
537-
},
538-
);
533+
duration
534+
})
535+
});
539536
}
540537
group.finish();
541538

542539
// Test 10k draw calls split up over 1, 2, 4, and 8 threads.
543540
let mut group = ctx.benchmark_group("Renderpass: Bindless");
544541
group.throughput(Throughput::Elements(draw_count as _));
545542

546-
group.bench_function(&format!("{draw_count} draws"), |b| {
543+
group.bench_function(format!("{draw_count} draws"), |b| {
547544
Lazy::force(&state);
548545

549546
b.iter_custom(|iters| {

benches/benches/resource_creation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn run_bench(ctx: &mut Criterion) {
1717
for threads in [1, 2, 4, 8] {
1818
let resources_per_thread = RESOURCES_TO_CREATE / threads;
1919
group.bench_function(
20-
&format!("{threads} threads x {resources_per_thread} resource"),
20+
format!("{threads} threads x {resources_per_thread} resource"),
2121
|b| {
2222
Lazy::force(&state);
2323

wgpu-core/src/command/compute_command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,15 @@ pub enum ArcComputeCommand {
215215
},
216216

217217
PushDebugGroup {
218+
#[cfg_attr(target_os = "emscripten", allow(dead_code))]
218219
color: u32,
219220
len: usize,
220221
},
221222

222223
PopDebugGroup,
223224

224225
InsertDebugMarker {
226+
#[cfg_attr(target_os = "emscripten", allow(dead_code))]
225227
color: u32,
226228
len: usize,
227229
},

wgpu-core/src/command/render_command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,13 @@ pub enum ArcRenderCommand {
464464
indexed: bool,
465465
},
466466
PushDebugGroup {
467+
#[cfg_attr(target_os = "emscripten", allow(dead_code))]
467468
color: u32,
468469
len: usize,
469470
},
470471
PopDebugGroup,
471472
InsertDebugMarker {
473+
#[cfg_attr(target_os = "emscripten", allow(dead_code))]
472474
color: u32,
473475
len: usize,
474476
},

wgpu-core/src/track/texture.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,9 @@ impl TextureTracker {
442442
let transitions = self
443443
.temp
444444
.drain(..)
445-
.map(|pending| {
445+
.inspect(|pending| {
446446
let tex = unsafe { self.metadata.get_resource_unchecked(pending.id as _) };
447447
textures.push(tex.inner.get(snatch_guard));
448-
pending
449448
})
450449
.collect();
451450
(transitions, textures)

wgpu-hal/src/vulkan/instance.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,9 @@ impl Drop for super::InstanceShared {
554554
fn drop(&mut self) {
555555
unsafe {
556556
// Keep du alive since destroy_instance may also log
557-
let _du = self.debug_utils.take().map(|du| {
557+
let _du = self.debug_utils.take().inspect(|du| {
558558
du.extension
559559
.destroy_debug_utils_messenger(du.messenger, None);
560-
du
561560
});
562561
if self.drop_guard.is_none() {
563562
self.raw.destroy_instance(None);

wgpu/src/api/queue.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ impl Drop for Queue {
3737
/// This type is unique to the Rust API of `wgpu`.
3838
/// There is no analogue in the WebGPU specification.
3939
#[derive(Debug, Clone)]
40-
pub struct SubmissionIndex(pub(crate) Arc<crate::Data>);
40+
pub struct SubmissionIndex {
41+
#[cfg_attr(not(native), allow(dead_code))]
42+
pub(crate) data: Arc<crate::Data>,
43+
}
4144
#[cfg(send_sync)]
4245
static_assertions::assert_impl_all!(SubmissionIndex: Send, Sync);
4346

@@ -248,7 +251,7 @@ impl Queue {
248251
let data =
249252
DynContext::queue_submit(&*self.context, self.data.as_ref(), &mut command_buffers);
250253

251-
SubmissionIndex(data)
254+
SubmissionIndex { data }
252255
}
253256

254257
/// Gets the amount of nanoseconds each tick of a timestamp query represents.

wgpu/src/backend/webgpu.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,14 +1403,6 @@ impl crate::context::Context for ContextWebGpu {
14031403
map_wgt_limits(device_data.0.limits())
14041404
}
14051405

1406-
fn device_downlevel_properties(
1407-
&self,
1408-
_device_data: &Self::DeviceData,
1409-
) -> wgt::DownlevelCapabilities {
1410-
// WebGPU is assumed to be fully compliant
1411-
wgt::DownlevelCapabilities::default()
1412-
}
1413-
14141406
#[cfg_attr(
14151407
not(any(
14161408
feature = "spirv",
@@ -2033,12 +2025,6 @@ impl crate::context::Context for ContextWebGpu {
20332025
device_data.0.destroy();
20342026
}
20352027

2036-
fn device_mark_lost(&self, _device_data: &Self::DeviceData, _message: &str) {
2037-
// TODO: figure out the GPUDevice implementation of this, including resolving
2038-
// the device.lost promise, which will require a different invocation pattern
2039-
// with a callback.
2040-
}
2041-
20422028
fn queue_drop(&self, _queue_data: &Self::QueueData) {
20432029
// Queue is dropped automatically
20442030
}
@@ -3023,52 +3009,6 @@ impl crate::context::Context for ContextWebGpu {
30233009
.draw_indexed_indirect_with_f64(&indirect_buffer_data.0.buffer, indirect_offset as f64);
30243010
}
30253011

3026-
fn render_bundle_encoder_multi_draw_indirect(
3027-
&self,
3028-
_encoder_data: &mut Self::RenderBundleEncoderData,
3029-
_indirect_buffer_data: &Self::BufferData,
3030-
_indirect_offset: wgt::BufferAddress,
3031-
_count: u32,
3032-
) {
3033-
panic!("MULTI_DRAW_INDIRECT feature must be enabled to call multi_draw_indirect")
3034-
}
3035-
3036-
fn render_bundle_encoder_multi_draw_indexed_indirect(
3037-
&self,
3038-
_encoder_data: &mut Self::RenderBundleEncoderData,
3039-
_indirect_buffer_data: &Self::BufferData,
3040-
_indirect_offset: wgt::BufferAddress,
3041-
_count: u32,
3042-
) {
3043-
panic!("MULTI_DRAW_INDIRECT feature must be enabled to call multi_draw_indexed_indirect")
3044-
}
3045-
3046-
fn render_bundle_encoder_multi_draw_indirect_count(
3047-
&self,
3048-
_encoder_data: &mut Self::RenderBundleEncoderData,
3049-
_indirect_buffer_data: &Self::BufferData,
3050-
_indirect_offset: wgt::BufferAddress,
3051-
_count_buffer_data: &Self::BufferData,
3052-
_count_buffer_offset: wgt::BufferAddress,
3053-
_max_count: u32,
3054-
) {
3055-
panic!(
3056-
"MULTI_DRAW_INDIRECT_COUNT feature must be enabled to call multi_draw_indirect_count"
3057-
)
3058-
}
3059-
3060-
fn render_bundle_encoder_multi_draw_indexed_indirect_count(
3061-
&self,
3062-
_encoder_data: &mut Self::RenderBundleEncoderData,
3063-
_indirect_buffer_data: &Self::BufferData,
3064-
_indirect_offset: wgt::BufferAddress,
3065-
_count_buffer_data: &Self::BufferData,
3066-
_count_buffer_offset: wgt::BufferAddress,
3067-
_max_count: u32,
3068-
) {
3069-
panic!("MULTI_DRAW_INDIRECT_COUNT feature must be enabled to call multi_draw_indexed_indirect_count")
3070-
}
3071-
30723012
fn render_pass_set_pipeline(
30733013
&self,
30743014
pass_data: &mut Self::RenderPassData,

wgpu/src/backend/wgpu_core.rs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,6 @@ impl crate::Context for ContextWgpuCore {
793793
}
794794
}
795795

796-
fn device_downlevel_properties(&self, device_data: &Self::DeviceData) -> DownlevelCapabilities {
797-
match self.0.device_downlevel_properties(device_data.id) {
798-
Ok(limits) => limits,
799-
Err(err) => self.handle_error_fatal(err, "Device::downlevel_properties"),
800-
}
801-
}
802-
803796
#[cfg_attr(
804797
not(any(
805798
feature = "spirv",
@@ -1374,17 +1367,12 @@ impl crate::Context for ContextWgpuCore {
13741367
fn device_destroy(&self, device_data: &Self::DeviceData) {
13751368
self.0.device_destroy(device_data.id);
13761369
}
1377-
fn device_mark_lost(&self, device_data: &Self::DeviceData, message: &str) {
1378-
// We do not provide a reason to device_lose, because all reasons other than
1379-
// destroyed (which this is not) are "unknown".
1380-
self.0.device_mark_lost(device_data.id, message);
1381-
}
13821370
fn device_poll(
13831371
&self,
13841372
device_data: &Self::DeviceData,
13851373
maintain: crate::Maintain,
13861374
) -> wgt::MaintainResult {
1387-
let maintain_inner = maintain.map_index(|i| *i.0.as_ref().downcast_ref().unwrap());
1375+
let maintain_inner = maintain.map_index(|i| *i.data.as_ref().downcast_ref().unwrap());
13881376
match self.0.device_poll(device_data.id, maintain_inner) {
13891377
Ok(done) => match done {
13901378
true => wgt::MaintainResult::SubmissionQueueEmpty,
@@ -2484,50 +2472,6 @@ impl crate::Context for ContextWgpuCore {
24842472
)
24852473
}
24862474

2487-
fn render_bundle_encoder_multi_draw_indirect(
2488-
&self,
2489-
_encoder_data: &mut Self::RenderBundleEncoderData,
2490-
_indirect_buffer_data: &Self::BufferData,
2491-
_indirect_offset: wgt::BufferAddress,
2492-
_count: u32,
2493-
) {
2494-
unimplemented!()
2495-
}
2496-
2497-
fn render_bundle_encoder_multi_draw_indexed_indirect(
2498-
&self,
2499-
_encoder_data: &mut Self::RenderBundleEncoderData,
2500-
_indirect_buffer_data: &Self::BufferData,
2501-
_indirect_offset: wgt::BufferAddress,
2502-
_count: u32,
2503-
) {
2504-
unimplemented!()
2505-
}
2506-
2507-
fn render_bundle_encoder_multi_draw_indirect_count(
2508-
&self,
2509-
_encoder_data: &mut Self::RenderBundleEncoderData,
2510-
_indirect_buffer_data: &Self::BufferData,
2511-
_indirect_offset: wgt::BufferAddress,
2512-
_count_buffer_data: &Self::BufferData,
2513-
_count_buffer_offset: wgt::BufferAddress,
2514-
_max_count: u32,
2515-
) {
2516-
unimplemented!()
2517-
}
2518-
2519-
fn render_bundle_encoder_multi_draw_indexed_indirect_count(
2520-
&self,
2521-
_encoder_data: &mut Self::RenderBundleEncoderData,
2522-
_indirect_buffer_data: &Self::BufferData,
2523-
_indirect_offset: wgt::BufferAddress,
2524-
_count_buffer_data: &Self::BufferData,
2525-
_count_buffer_offset: wgt::BufferAddress,
2526-
_max_count: u32,
2527-
) {
2528-
unimplemented!()
2529-
}
2530-
25312475
fn render_pass_set_pipeline(
25322476
&self,
25332477
pass_data: &mut Self::RenderPassData,

0 commit comments

Comments
 (0)