Skip to content

Commit d9cc727

Browse files
Use more Rust features allowed under REPO_MSRV (#6887)
* chore: remove `std::mem::*` imports now unnecessary with `REPO_MSRV` `std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust 1.80; see [`rust`#123168](rust-lang/rust#123168). * refactor(benches): s/once_cell::Lazy/std::sync::LazyLock Weaken our dependence on the `once_cell` crate by using functionality from `std` instead that was upstreamed from `once_cell`, this time with what's available in Rust 1.80+. It's not yet possible to eliminate this dependency entirely, but do what we can with `REPO_MSRV` for now. * chore: remove unnecessarily `allow`'d lint rules under `REPO_MSRV` * chore: migrate easy `allow`s to `expect` under `REPO_MSRV` Remove or `expect` clear-cut `allow` statements that were easy for me to figure out. * chore: `warn` on `clippy::allow_attributes` under `REPO_MSRV`
1 parent 450ac2d commit d9cc727

File tree

51 files changed

+103
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+103
-105
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benches/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ naga = { workspace = true, features = [
4343
"wgsl-out",
4444
] }
4545
nanorand.workspace = true
46-
once_cell.workspace = true
4746
pollster.workspace = true
4847
profiling.workspace = true
4948
rayon.workspace = true

benches/benches/bind_groups.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55

66
use criterion::{criterion_group, Criterion, Throughput};
77
use nanorand::{Rng, WyRand};
8-
use once_cell::sync::Lazy;
8+
use std::sync::LazyLock;
99

1010
use crate::DeviceState;
1111

@@ -60,7 +60,7 @@ impl BindGroupState {
6060
}
6161

6262
fn run_bench(ctx: &mut Criterion) {
63-
let state = Lazy::new(BindGroupState::new);
63+
let state = LazyLock::new(BindGroupState::new);
6464

6565
if !state
6666
.device_state

benches/benches/computepass.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::{
55

66
use criterion::{criterion_group, Criterion, Throughput};
77
use nanorand::{Rng, WyRand};
8-
use once_cell::sync::Lazy;
98
use rayon::iter::{IntoParallelIterator, ParallelIterator};
9+
use std::sync::LazyLock;
1010

1111
use crate::DeviceState;
1212

@@ -424,7 +424,7 @@ impl ComputepassState {
424424
}
425425

426426
fn run_bench(ctx: &mut Criterion) {
427-
let state = Lazy::new(ComputepassState::new);
427+
let state = LazyLock::new(ComputepassState::new);
428428

429429
let dispatch_count = dispatch_count();
430430
let dispatch_count_bindless = dispatch_count_bindless();
@@ -449,7 +449,7 @@ fn run_bench(ctx: &mut Criterion) {
449449
group.bench_function(
450450
format!("{cpasses} computepasses x {dispatch_per_pass} dispatches ({label})"),
451451
|b| {
452-
Lazy::force(&state);
452+
LazyLock::force(&state);
453453

454454
b.iter_custom(|iters| {
455455
profiling::scope!("benchmark invocation");
@@ -498,7 +498,7 @@ fn run_bench(ctx: &mut Criterion) {
498498
group.bench_function(
499499
format!("{threads} threads x {dispatch_per_pass} dispatch"),
500500
|b| {
501-
Lazy::force(&state);
501+
LazyLock::force(&state);
502502

503503
b.iter_custom(|iters| {
504504
profiling::scope!("benchmark invocation");
@@ -538,7 +538,7 @@ fn run_bench(ctx: &mut Criterion) {
538538
group.throughput(Throughput::Elements(dispatch_count_bindless as _));
539539

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

543543
b.iter_custom(|iters| {
544544
profiling::scope!("benchmark invocation");
@@ -579,7 +579,7 @@ fn run_bench(ctx: &mut Criterion) {
579579
texture_count + storage_texture_count + storage_buffer_count
580580
),
581581
|b| {
582-
Lazy::force(&state);
582+
LazyLock::force(&state);
583583

584584
b.iter(|| state.device_state.queue.submit([]));
585585
},

benches/benches/renderpass.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::{
55

66
use criterion::{criterion_group, Criterion, Throughput};
77
use nanorand::{Rng, WyRand};
8-
use once_cell::sync::Lazy;
98
use rayon::iter::{IntoParallelIterator, ParallelIterator};
9+
use std::sync::LazyLock;
1010

1111
use crate::DeviceState;
1212

@@ -427,7 +427,7 @@ impl RenderpassState {
427427
}
428428

429429
fn run_bench(ctx: &mut Criterion) {
430-
let state = Lazy::new(RenderpassState::new);
430+
let state = LazyLock::new(RenderpassState::new);
431431

432432
let draw_count = draw_count();
433433
let vertex_buffer_count = draw_count * VERTEX_BUFFERS_PER_DRAW;
@@ -450,7 +450,7 @@ fn run_bench(ctx: &mut Criterion) {
450450
group.bench_function(
451451
format!("{rpasses} renderpasses x {draws_per_pass} draws ({label})"),
452452
|b| {
453-
Lazy::force(&state);
453+
LazyLock::force(&state);
454454

455455
b.iter_custom(|iters| {
456456
profiling::scope!("benchmark invocation");
@@ -502,7 +502,7 @@ fn run_bench(ctx: &mut Criterion) {
502502
for threads in [2, 4, 8] {
503503
let draws_per_pass = draw_count / threads;
504504
group.bench_function(format!("{threads} threads x {draws_per_pass} draws"), |b| {
505-
Lazy::force(&state);
505+
LazyLock::force(&state);
506506

507507
b.iter_custom(|iters| {
508508
profiling::scope!("benchmark invocation");
@@ -541,7 +541,7 @@ fn run_bench(ctx: &mut Criterion) {
541541
group.throughput(Throughput::Elements(draw_count as _));
542542

543543
group.bench_function(format!("{draw_count} draws"), |b| {
544-
Lazy::force(&state);
544+
LazyLock::force(&state);
545545

546546
b.iter_custom(|iters| {
547547
profiling::scope!("benchmark invocation");
@@ -577,7 +577,7 @@ fn run_bench(ctx: &mut Criterion) {
577577
texture_count + vertex_buffer_count
578578
),
579579
|b| {
580-
Lazy::force(&state);
580+
LazyLock::force(&state);
581581

582582
b.iter(|| state.device_state.queue.submit([]));
583583
},

benches/benches/resource_creation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::time::{Duration, Instant};
22

33
use criterion::{criterion_group, Criterion, Throughput};
4-
use once_cell::sync::Lazy;
54
use rayon::iter::{IntoParallelIterator, ParallelIterator};
5+
use std::sync::LazyLock;
66

77
use crate::DeviceState;
88

99
fn run_bench(ctx: &mut Criterion) {
10-
let state = Lazy::new(DeviceState::new);
10+
let state = LazyLock::new(DeviceState::new);
1111

1212
const RESOURCES_TO_CREATE: usize = 8;
1313

@@ -19,7 +19,7 @@ fn run_bench(ctx: &mut Criterion) {
1919
group.bench_function(
2020
format!("{threads} threads x {resources_per_thread} resource"),
2121
|b| {
22-
Lazy::force(&state);
22+
LazyLock::force(&state);
2323

2424
b.iter_custom(|iters| {
2525
profiling::scope!("benchmark invocation");

examples/src/boids/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// adapted from https://github.com/austinEng/webgpu-samples/blob/master/src/examples/computeBoids.ts
33

44
use nanorand::{Rng, WyRand};
5-
use std::mem::size_of;
65
use wgpu::util::DeviceExt;
76

87
// number of boid particles to simulate

examples/src/bunnymark/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bytemuck::{Pod, Zeroable};
22
use nanorand::{Rng, WyRand};
3-
use std::{borrow::Cow, mem::size_of};
3+
use std::borrow::Cow;
44
use wgpu::util::DeviceExt;
55
use winit::{
66
event::{ElementState, KeyEvent},

examples/src/cube/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bytemuck::{Pod, Zeroable};
2-
use std::{f32::consts, mem::size_of};
2+
use std::f32::consts;
33
use wgpu::util::DeviceExt;
44

55
#[repr(C)]

examples/src/framework.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ async fn start<E: Example>(title: &str) {
362362
}
363363

364364
log::info!("Entering event loop...");
365-
// On native this is a result, but on wasm it's a unit type.
366-
#[allow(clippy::let_unit_value)]
365+
#[cfg_attr(target_arch = "wasm32", expect(clippy::let_unit_value))]
367366
let _ = (event_loop_function)(
368367
window_loop.event_loop,
369368
move |event: Event<()>, target: &EventLoopWindowTarget<()>| {

0 commit comments

Comments
 (0)