From 68466a95c680b7911dfd8220a9b5697246c17135 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:58:55 +0000 Subject: [PATCH 01/10] Update to MSRV 1.82 in preparation for color --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 4 ++-- Cargo.toml | 6 ++++-- README.md | 2 +- examples/scenes/src/lib.rs | 3 +-- examples/scenes/src/test_scenes.rs | 5 ++++- examples/with_winit/src/stats.rs | 5 ++++- vello/README.md | 2 +- vello/src/debug/renderer.rs | 14 +++++++++----- vello/src/debug/validate.rs | 6 ++++++ vello/src/lib.rs | 25 ++++++++++++++++--------- vello/src/recording.rs | 5 ++++- vello/src/render.rs | 4 ---- vello/src/util.rs | 13 +++++++++++-- vello/src/wgpu_engine.rs | 22 +++++++++++++++++----- vello_encoding/README.md | 3 ++- vello_encoding/src/clip.rs | 5 ++++- vello_encoding/src/config.rs | 6 +----- vello_encoding/src/lib.rs | 9 +++++---- vello_encoding/src/math.rs | 1 - vello_encoding/src/path.rs | 9 ++++----- vello_encoding/src/resolve.rs | 4 ---- vello_shaders/README.md | 3 ++- vello_shaders/build.rs | 14 ++++++++++++-- vello_shaders/src/compile/mod.rs | 9 ++++----- vello_shaders/src/cpu.rs | 10 +++++----- vello_shaders/src/cpu/euler.rs | 8 +++++--- vello_shaders/src/cpu/fine.rs | 4 +--- vello_shaders/src/cpu/flatten.rs | 4 ---- vello_shaders/src/lib.rs | 7 ++++--- vello_shaders/src/types.rs | 9 --------- 31 files changed, 130 insertions(+), 93 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7938cfccc..8c331aca6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ env: # If the compilation fails, then the version specified here needs to be bumped up to reality. # Be sure to also update the rust-version property in the workspace Cargo.toml file, # plus all the README.md files of the affected packages. - RUST_MIN_VER: "1.76" + RUST_MIN_VER: "1.82" # List of packages that will be checked with the minimum supported Rust version. # This should be limited to packages that are intended for publishing. RUST_MIN_VER_PKGS: "-p vello -p vello_encoding -p vello_shaders" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0982f03c8..938335202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,11 @@ You can find its changes [documented below](#030---2024-10-04). ## [Unreleased] -This release has an [MSRV][] of 1.76. +This release has an [MSRV][] of 1.82. ### Changed -- Breaking: Updated `wgpu` to 23.0.1, increased MSRV to 1.76 ([#735][], [#743][] by [@waywardmonkeys]) +- Breaking: Updated `wgpu` to 23.0.1 ([#735][], [#743][] by [@waywardmonkeys]) ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 473192554..d2c4e87f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ version = "0.3.0" edition = "2021" # Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml, with the relevant README.md files # and with the MSRV in the `Unreleased` section of CHANGELOG.md. -rust-version = "1.76" +rust-version = "1.82" license = "Apache-2.0 OR MIT" repository = "https://github.com/linebender/vello" @@ -63,7 +63,9 @@ clippy.dbg_macro = "warn" clippy.debug_assert_with_mut_call = "warn" clippy.doc_markdown = "warn" clippy.exhaustive_enums = "warn" -clippy.fn_to_numeric_cast_any = "warn" # Can't be forbid due to 'scenes' requiring an exception. +# Break from the lint set due to https://github.com/rust-lang/rust/issues/133346#issuecomment-2503567552 +# and our use of clap. +clippy.fn_to_numeric_cast_any = "deny" clippy.infinite_loop = "warn" clippy.large_include_file = "warn" clippy.large_stack_arrays = "warn" diff --git a/README.md b/README.md index acb7c28aa..44f9a2efe 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ VELLO_STATIC_LOG="vello=trace" VELLO_STATIC_ARGS="--test-scenes" cargo apk run - ## Minimum supported Rust Version (MSRV) -This version of Vello has been verified to compile with **Rust 1.76** and later. +This version of Vello has been verified to compile with **Rust 1.82** and later. Future versions of Vello might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. diff --git a/examples/scenes/src/lib.rs b/examples/scenes/src/lib.rs index 06e21d79a..3248a1bc8 100644 --- a/examples/scenes/src/lib.rs +++ b/examples/scenes/src/lib.rs @@ -22,8 +22,7 @@ clippy::use_self, clippy::match_same_arms, clippy::allow_attributes_without_reason, - clippy::allow_attributes, - clippy::fn_to_numeric_cast_any + clippy::allow_attributes )] mod images; diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index 583188071..9e3e60542 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs @@ -882,7 +882,10 @@ mod impls { params.resolution = Some((1200.0, 1200.0).into()); } - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "This function is internal, so the argument count doesn't cause issues for consumers." + )] pub(super) fn two_point_radial(scene: &mut Scene, _params: &mut SceneParams) { pub(super) fn make( scene: &mut Scene, diff --git a/examples/with_winit/src/stats.rs b/examples/with_winit/src/stats.rs index bd4b12ec8..687803e57 100644 --- a/examples/with_winit/src/stats.rs +++ b/examples/with_winit/src/stats.rs @@ -25,7 +25,10 @@ pub struct Snapshot { } impl Snapshot { - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "This function is internal, so the argument count doesn't cause issues for consumers." + )] pub fn draw_layer<'a, T>( &self, scene: &mut Scene, diff --git a/vello/README.md b/vello/README.md index cb5f87278..2e47cd72a 100644 --- a/vello/README.md +++ b/vello/README.md @@ -220,7 +220,7 @@ VELLO_STATIC_LOG="vello=trace" VELLO_STATIC_ARGS="--test-scenes" cargo apk run - ## Minimum supported Rust Version (MSRV) -This version of Vello has been verified to compile with **Rust 1.76** and later. +This version of Vello has been verified to compile with **Rust 1.82** and later. Future versions of Vello might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. diff --git a/vello/src/debug/renderer.rs b/vello/src/debug/renderer.rs index 139de1821..0d50430d3 100644 --- a/vello/src/debug/renderer.rs +++ b/vello/src/debug/renderer.rs @@ -1,9 +1,11 @@ // Copyright 2023 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; +#![expect( + clippy::allow_attributes, + clippy::allow_attributes_without_reason, + reason = "Generated by derive macro" +)] use super::DebugLayers; use crate::{ @@ -211,8 +213,10 @@ impl DebugRenderer { } } - #[allow(clippy::too_many_arguments)] - // #[expect(clippy::too_many_arguments, reason="This function is internal, so the argument count doesn't cause issues for consumers.")] + #[expect( + clippy::too_many_arguments, + reason = "This function is internal, so the argument count doesn't cause issues for consumers." + )] pub fn render( &self, recording: &mut Recording, diff --git a/vello/src/debug/validate.rs b/vello/src/debug/validate.rs index d3bd6e5d3..b570f8d6c 100644 --- a/vello/src/debug/validate.rs +++ b/vello/src/debug/validate.rs @@ -1,6 +1,12 @@ // Copyright 2023 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT +#![expect( + clippy::allow_attributes, + clippy::allow_attributes_without_reason, + reason = "Generated by derive macro" +)] + use { bytemuck::{Pod, Zeroable}, std::{collections::BTreeSet, fmt}, diff --git a/vello/src/lib.rs b/vello/src/lib.rs index 1e7760ce3..480f99122 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -92,13 +92,14 @@ // The following lints are part of the Linebender standard set, // but resolving them has been deferred for now. // Feel free to send a PR that solves one or more of these. -#![allow( +// Allow because of: https://github.com/rust-lang/rust/pull/130025 +#![allow(missing_docs, reason = "We have many as-yet undocumented items.")] +#![expect( missing_debug_implementations, elided_lifetimes_in_paths, single_use_lifetimes, unnameable_types, unreachable_pub, - missing_docs, clippy::return_self_not_must_use, clippy::cast_possible_truncation, clippy::missing_assert_message, @@ -110,13 +111,10 @@ clippy::print_stderr, clippy::partial_pub_fields, clippy::use_self, - clippy::match_same_arms + clippy::match_same_arms, + reason = "Deferred" )] -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; - mod debug; mod recording; mod render; @@ -321,7 +319,10 @@ pub enum Error { ShaderCompilation(#[from] vello_shaders::compile::ErrorVec), } -#[allow(dead_code)] // this can be unused when wgpu feature is not used +#[cfg_attr( + not(feature = "wgpu"), + expect(dead_code, reason = "this can be unused when wgpu feature is not used") +)] pub(crate) type Result = std::result::Result; /// Renders a scene into a texture or surface. @@ -331,7 +332,13 @@ pub(crate) type Result = std::result::Result; /// This is an assumption which is known to be limiting, and is planned to change. #[cfg(feature = "wgpu")] pub struct Renderer { - #[cfg_attr(not(feature = "hot_reload"), allow(dead_code))] + #[cfg_attr( + not(feature = "hot_reload"), + expect( + dead_code, + reason = "Options are only used to reinitialise on a hot reload" + ) + )] options: RendererOptions, engine: WgpuEngine, resolver: Resolver, diff --git a/vello/src/recording.rs b/vello/src/recording.rs index 503d65cdb..c70816d71 100644 --- a/vello/src/recording.rs +++ b/vello/src/recording.rs @@ -168,7 +168,10 @@ impl Recording { /// Dispatch a compute shader where the size is determined dynamically. /// The `buf` argument contains the dispatch size, 3 `u32` values beginning /// at the given byte `offset`. - #[allow(unused)] + #[cfg_attr( + not(feature = "debug_layers"), + expect(unused, reason = "Currently only used by the debug layers") + )] pub fn dispatch_indirect( &mut self, shader: ShaderId, diff --git a/vello/src/render.rs b/vello/src/render.rs index fd31574dd..521554b4a 100644 --- a/vello/src/render.rs +++ b/vello/src/render.rs @@ -3,10 +3,6 @@ //! Take an encoded scene and create a graph to render it -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; - use crate::recording::{BufferProxy, ImageFormat, ImageProxy, Recording, ResourceProxy}; use crate::shaders::FullShaders; use crate::{AaConfig, RenderParams}; diff --git a/vello/src/util.rs b/vello/src/util.rs index cbc1c5b83..beb0efe4e 100644 --- a/vello/src/util.rs +++ b/vello/src/util.rs @@ -25,7 +25,10 @@ pub struct DeviceHandle { } impl RenderContext { - #[allow(clippy::new_without_default)] + #[expect( + clippy::new_without_default, + reason = "Creating a wgpu Instance is something which should only be done rarely" + )] pub fn new() -> Self { let instance = Instance::new(wgpu::InstanceDescriptor { backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY), @@ -137,7 +140,13 @@ impl RenderContext { .await?; let features = adapter.features(); let limits = Limits::default(); - #[allow(unused_mut)] + #[cfg_attr( + not(feature = "wgpu-profiler"), + expect( + unused_mut, + reason = "Mutation is only expected with the wgpu-profiler feature" + ) + )] let mut maybe_features = wgpu::Features::CLEAR_TEXTURE; #[cfg(feature = "wgpu-profiler")] { diff --git a/vello/src/wgpu_engine.rs b/vello/src/wgpu_engine.rs index 1c8016ced..148683710 100644 --- a/vello/src/wgpu_engine.rs +++ b/vello/src/wgpu_engine.rs @@ -70,7 +70,6 @@ enum ShaderKind<'a> { } struct Shader { - #[allow(dead_code)] label: &'static str, wgpu: Option, cpu: Option, @@ -89,7 +88,7 @@ impl Shader { } pub(crate) enum ExternalResource<'a> { - #[allow(unused)] + #[expect(unused, reason = "No buffers are accepted as arguments currently")] Buffer(BufferProxy, &'a Buffer), Image(ImageProxy, &'a TextureView), } @@ -303,7 +302,10 @@ impl WgpuEngine { }) } - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "This function is internal, so the argument count doesn't cause issues for consumers." + )] pub fn add_render_shader( &mut self, device: &Device, @@ -936,7 +938,14 @@ impl ResourcePool { fn get_buf( &mut self, size: u64, - #[allow(unused)] name: &'static str, + #[cfg_attr( + not(feature = "buffer_labels"), + expect( + unused, + reason = "Debugging argument always present but only consumed when debugging feature enabled" + ) + )] + name: &'static str, usage: BufferUsages, device: &Device, ) -> Buffer { @@ -1041,7 +1050,10 @@ impl<'a> TransientBindMap<'a> { .expect("texture not materialized") } - #[allow(clippy::too_many_arguments)] + #[expect( + clippy::too_many_arguments, + reason = "This function is internal, so the argument count doesn't cause issues for consumers." + )] fn create_bind_group( &mut self, bind_map: &mut BindMap, diff --git a/vello_encoding/README.md b/vello_encoding/README.md index 03d5aaafd..c76d1fdeb 100644 --- a/vello_encoding/README.md +++ b/vello_encoding/README.md @@ -20,7 +20,7 @@ Significant changes are documented in [the changelog]. ## Minimum supported Rust Version (MSRV) -This version of Vello Encoding has been verified to compile with **Rust 1.76** and later. +This version of Vello Encoding has been verified to compile with **Rust 1.82** and later. Future versions of Vello Encoding might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. @@ -35,6 +35,7 @@ If you encounter a compilation issue due to a dependency and don't want to upgra # Use the problematic dependency's name and version cargo update -p package_name --precise 0.1.1 ``` + ## Community diff --git a/vello_encoding/src/clip.rs b/vello_encoding/src/clip.rs index 52cd80671..228d7acf5 100644 --- a/vello_encoding/src/clip.rs +++ b/vello_encoding/src/clip.rs @@ -22,7 +22,10 @@ pub struct ClipBic { /// Clip element. #[derive(Copy, Clone, Pod, Zeroable, Debug, Default)] #[repr(C)] -#[allow(clippy::partial_pub_fields)] +#[expect( + clippy::partial_pub_fields, + reason = "Padding is meaningless to manipulate directly" +)] pub struct ClipElement { pub parent_ix: u32, _padding: [u8; 12], diff --git a/vello_encoding/src/config.rs b/vello_encoding/src/config.rs index 3d0b2ba8b..8f155498f 100644 --- a/vello_encoding/src/config.rs +++ b/vello_encoding/src/config.rs @@ -1,10 +1,6 @@ // Copyright 2023 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; - use crate::SegmentCount; use super::{ @@ -304,7 +300,7 @@ impl BufferSize { } /// Returns the number of elements. - #[allow(clippy::len_without_is_empty)] + #[expect(clippy::len_without_is_empty, reason = "The buffer can never be empty")] pub const fn len(self) -> u32 { self.len } diff --git a/vello_encoding/src/lib.rs b/vello_encoding/src/lib.rs index cc792422e..57c4d702f 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -14,20 +14,21 @@ // The following lints are part of the Linebender standard set, // but resolving them has been deferred for now. // Feel free to send a PR that solves one or more of these. -#![allow( +// Allow because of: https://github.com/rust-lang/rust/pull/130025 +#![allow(missing_docs, reason = "We have many as-yet undocumented items.")] +#![expect( missing_debug_implementations, elided_lifetimes_in_paths, single_use_lifetimes, unnameable_types, - missing_docs, - variant_size_differences, clippy::return_self_not_must_use, clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, clippy::missing_assert_message, clippy::shadow_unrelated, clippy::missing_panics_doc, - clippy::exhaustive_enums + clippy::exhaustive_enums, + reason = "Deferred" )] mod binning; diff --git a/vello_encoding/src/math.rs b/vello_encoding/src/math.rs index 14432bed4..8989698af 100644 --- a/vello_encoding/src/math.rs +++ b/vello_encoding/src/math.rs @@ -72,7 +72,6 @@ impl Mul for Transform { } } -#[allow(dead_code)] pub fn point_to_f32(point: kurbo::Point) -> [f32; 2] { [point.x as f32, point.y as f32] } diff --git a/vello_encoding/src/path.rs b/vello_encoding/src/path.rs index 8d9423ac8..06ac051af 100644 --- a/vello_encoding/src/path.rs +++ b/vello_encoding/src/path.rs @@ -1,10 +1,6 @@ // Copyright 2022 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; - use bytemuck::{Pod, Zeroable}; use peniko::kurbo::{Cap, Join, Shape, Stroke}; use peniko::Fill; @@ -394,7 +390,10 @@ pub struct PathBbox { /// Tiled path object. #[derive(Copy, Clone, Pod, Zeroable, Debug, Default)] #[repr(C)] -#[allow(clippy::partial_pub_fields)] +#[expect( + clippy::partial_pub_fields, + reason = "Padding is meaningless to manipulate directly" +)] pub struct Path { /// Bounding box in tiles. pub bbox: [u32; 4], diff --git a/vello_encoding/src/resolve.rs b/vello_encoding/src/resolve.rs index 50f81ba57..44a98aa1f 100644 --- a/vello_encoding/src/resolve.rs +++ b/vello_encoding/src/resolve.rs @@ -1,10 +1,6 @@ // Copyright 2022 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; - use bytemuck::{Pod, Zeroable}; use super::{DrawTag, Encoding, PathTag, StreamOffsets, Style, Transform}; diff --git a/vello_shaders/README.md b/vello_shaders/README.md index bb340efd6..d402b70f4 100644 --- a/vello_shaders/README.md +++ b/vello_shaders/README.md @@ -24,7 +24,7 @@ Significant changes are documented in [the changelog]. ## Minimum supported Rust Version (MSRV) -This version of Vello Shaders has been verified to compile with **Rust 1.76** and later. +This version of Vello Shaders has been verified to compile with **Rust 1.82** and later. Future versions of Vello Shaders might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases. @@ -39,6 +39,7 @@ If you encounter a compilation issue due to a dependency and don't want to upgra # Use the problematic dependency's name and version cargo update -p package_name --precise 0.1.1 ``` + ## Community diff --git a/vello_shaders/build.rs b/vello_shaders/build.rs index cc70bd9b0..2e7c6907f 100644 --- a/vello_shaders/build.rs +++ b/vello_shaders/build.rs @@ -4,10 +4,20 @@ //! Build step. // These modules are also included in the main crate, where the items are reachable -#[allow(unreachable_pub, unused)] +#[allow( + clippy::allow_attributes, + unreachable_pub, + unused, + reason = "Checked elsewhere" +)] #[path = "src/compile/mod.rs"] mod compile; -#[allow(unreachable_pub, unused)] +#[allow( + clippy::allow_attributes, + unreachable_pub, + unused, + reason = "Checked elsewhere" +)] #[path = "src/types.rs"] mod types; diff --git a/vello_shaders/src/compile/mod.rs b/vello_shaders/src/compile/mod.rs index 772fa35f9..db18352f8 100644 --- a/vello_shaders/src/compile/mod.rs +++ b/vello_shaders/src/compile/mod.rs @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT // Pending on https://github.com/rust-lang/rust-clippy/pull/13677 -#![allow(clippy::shadow_unrelated)] -// The following lints are part of the Linebender standard set, -// but resolving them has been deferred for now. -// Feel free to send a PR that solves one or more of these. -#![allow(clippy::missing_assert_message, clippy::missing_errors_doc)] +#![expect( + clippy::shadow_unrelated, + reason = "https://github.com/rust-lang/rust-clippy/pull/13677" +)] use naga::front::wgsl; use naga::valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags}; diff --git a/vello_shaders/src/cpu.rs b/vello_shaders/src/cpu.rs index dde7928fc..89be76c1b 100644 --- a/vello_shaders/src/cpu.rs +++ b/vello_shaders/src/cpu.rs @@ -7,8 +7,11 @@ //! a full CPU fallback as an alternative to GPU shaders is not provided. // Allow un-idiomatic Rust to more closely match shaders -#![allow(clippy::needless_range_loop)] -#![allow(clippy::too_many_arguments)] +#![expect( + clippy::needless_range_loop, + clippy::too_many_arguments, + reason = "Keeps code easily comparable to GPU shaders" +)] mod backdrop; mod bbox_clear; @@ -56,7 +59,6 @@ use bytemuck::Pod; pub enum CpuBinding<'a> { Buffer(&'a [u8]), BufferRW(&'a RefCell>), - #[allow(unused)] Texture(&'a CpuTexture), } @@ -66,7 +68,6 @@ pub enum TypedBufGuard<'a, T: ?Sized> { } pub enum TypedBufGuardMut<'a, T: ?Sized> { - #[allow(dead_code)] Slice(&'a mut T), Interior(RefMut<'a, T>), } @@ -148,7 +149,6 @@ impl<'a> CpuBinding<'a> { } // TODO: same guard as buf to make mutable - #[allow(unused)] pub fn as_tex(&self) -> &CpuTexture { match self { CpuBinding::Texture(t) => t, diff --git a/vello_shaders/src/cpu/euler.rs b/vello_shaders/src/cpu/euler.rs index fbe0bbea2..ddf0bc7d0 100644 --- a/vello_shaders/src/cpu/euler.rs +++ b/vello_shaders/src/cpu/euler.rs @@ -3,8 +3,10 @@ //! Utility functions for Euler Spiral based stroke expansion. -// Use the same constants as the f64 version. -#![allow(clippy::excessive_precision)] +#![expect( + clippy::excessive_precision, + reason = "Uses the same constants as the f64 version" +)] use super::util::Vec2; use std::f32::consts::FRAC_PI_4; @@ -217,7 +219,7 @@ impl EulerSeg { Self { p0, p1, params } } - #[allow(unused)] + #[expect(unused, reason = "Unclear why this code exists")] pub(crate) fn eval(&self, t: f32) -> Vec2 { let Vec2 { x, y } = self.params.eval(t); let chord = self.p1 - self.p0; diff --git a/vello_shaders/src/cpu/fine.rs b/vello_shaders/src/cpu/fine.rs index 0636e24ee..3b6bd3b5b 100644 --- a/vello_shaders/src/cpu/fine.rs +++ b/vello_shaders/src/cpu/fine.rs @@ -108,9 +108,7 @@ fn fill_path(area: &mut [f32], segments: &[PathSegment], fill: &CmdFill, x_tile: } } -// Note: this is a draft. Texture resources are not yet wired up, so it -// has not yet been tested. -#[allow(unused)] +#[expect(unused, reason = "Draft code as textures not wired up")] fn fine_main( config: &ConfigUniform, tiles: &[Tile], diff --git a/vello_shaders/src/cpu/flatten.rs b/vello_shaders/src/cpu/flatten.rs index b298de8dd..d4e51d251 100644 --- a/vello_shaders/src/cpu/flatten.rs +++ b/vello_shaders/src/cpu/flatten.rs @@ -1,10 +1,6 @@ // Copyright 2023 the Vello Authors // SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense -// size_of is not part of the prelude until Rust 1.80 and our MSRV is below that -#[allow(unused_imports)] -use core::mem::size_of; - use std::f32::consts::FRAC_1_SQRT_2; use super::{ diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index 8dfc42f86..3e167546e 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -28,12 +28,13 @@ // The following lints are part of the Linebender standard set, // but resolving them has been deferred for now. // Feel free to send a PR that solves one or more of these. -#![allow( +// Allow because of: https://github.com/rust-lang/rust/pull/130025 +#![allow(missing_docs, reason = "We have many as-yet undocumented items.")] +#![expect( missing_debug_implementations, elided_lifetimes_in_paths, single_use_lifetimes, unnameable_types, - missing_docs, clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, clippy::missing_assert_message, @@ -41,7 +42,7 @@ clippy::missing_panics_doc, clippy::exhaustive_enums, clippy::todo, - clippy::print_stderr + reason = "Deferred" )] mod types; diff --git a/vello_shaders/src/types.rs b/vello_shaders/src/types.rs index 2b2cd05f2..76bb235e7 100644 --- a/vello_shaders/src/types.rs +++ b/vello_shaders/src/types.rs @@ -3,11 +3,6 @@ //! Types that are shared between the main crate and build. -// The following lints are part of the Linebender standard set, -// but resolving them has been deferred for now. -// Feel free to send a PR that solves one or more of these. -#![allow(elided_lifetimes_in_paths)] - /// The type of resource that will be bound to a slot in a shader. #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum BindType { @@ -25,10 +20,6 @@ pub enum BindType { } impl BindType { - // TODO: This is a public method, which means it definitely is not - // "dead code". However, rustc seems insitent that it is, and so to not - // block forward progress, I shall humour it - #[allow(dead_code)] pub fn is_mutable(self) -> bool { matches!(self, Self::Buffer | Self::Image) } From 38ef5c47e8ce28049a10e63861526a0bba59c238 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:53:57 +0000 Subject: [PATCH 02/10] Fix a CI pass --- vello/src/lib.rs | 23 ++++++++++++++++++++--- vello/src/recording.rs | 4 ---- vello/src/wgpu_engine.rs | 8 +++++++- vello_encoding/src/lib.rs | 9 ++++++--- vello_shaders/build.rs | 19 ++++++------------- vello_shaders/src/lib.rs | 12 +++++++++--- vello_shaders/src/types.rs | 2 +- 7 files changed, 49 insertions(+), 28 deletions(-) diff --git a/vello/src/lib.rs b/vello/src/lib.rs index 480f99122..7a0d04dc5 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -105,15 +105,32 @@ clippy::missing_assert_message, clippy::shadow_unrelated, clippy::missing_panics_doc, - clippy::missing_errors_doc, clippy::exhaustive_enums, - clippy::todo, clippy::print_stderr, - clippy::partial_pub_fields, clippy::use_self, clippy::match_same_arms, reason = "Deferred" )] +#![allow( + // missing_debug_implementations, + // elided_lifetimes_in_paths, + // single_use_lifetimes, + // unnameable_types, + // unreachable_pub, + // clippy::return_self_not_must_use, + // clippy::cast_possible_truncation, + // clippy::missing_assert_message, + // clippy::shadow_unrelated, + // clippy::missing_panics_doc, + clippy::missing_errors_doc, + // clippy::exhaustive_enums, + clippy::todo, + // clippy::print_stderr, + clippy::partial_pub_fields, + // clippy::use_self, + // clippy::match_same_arms, + reason = "Deferred, only apply in some feature sets so not expect" +)] mod debug; mod recording; diff --git a/vello/src/recording.rs b/vello/src/recording.rs index c70816d71..0edebab7a 100644 --- a/vello/src/recording.rs +++ b/vello/src/recording.rs @@ -168,10 +168,6 @@ impl Recording { /// Dispatch a compute shader where the size is determined dynamically. /// The `buf` argument contains the dispatch size, 3 `u32` values beginning /// at the given byte `offset`. - #[cfg_attr( - not(feature = "debug_layers"), - expect(unused, reason = "Currently only used by the debug layers") - )] pub fn dispatch_indirect( &mut self, shader: ShaderId, diff --git a/vello/src/wgpu_engine.rs b/vello/src/wgpu_engine.rs index 148683710..f00974ed7 100644 --- a/vello/src/wgpu_engine.rs +++ b/vello/src/wgpu_engine.rs @@ -101,7 +101,13 @@ enum MaterializedBuffer { struct BindMapBuffer { buffer: MaterializedBuffer, - #[cfg_attr(not(feature = "buffer_labels"), allow(unused))] + #[cfg_attr( + not(feature = "buffer_labels"), + expect( + unused, + reason = "Useful for debugging; simplifies upstream to always provide this" + ) + )] label: &'static str, } diff --git a/vello_encoding/src/lib.rs b/vello_encoding/src/lib.rs index 57c4d702f..aa8cbed22 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -20,16 +20,19 @@ missing_debug_implementations, elided_lifetimes_in_paths, single_use_lifetimes, - unnameable_types, clippy::return_self_not_must_use, clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, clippy::missing_assert_message, - clippy::shadow_unrelated, clippy::missing_panics_doc, - clippy::exhaustive_enums, reason = "Deferred" )] +#![allow( + unnameable_types, + clippy::shadow_unrelated, + clippy::exhaustive_enums, + reason = "Deferred, only apply in some feature sets so not expect" +)] mod binning; mod clip; diff --git a/vello_shaders/build.rs b/vello_shaders/build.rs index 2e7c6907f..62878670a 100644 --- a/vello_shaders/build.rs +++ b/vello_shaders/build.rs @@ -4,20 +4,10 @@ //! Build step. // These modules are also included in the main crate, where the items are reachable -#[allow( - clippy::allow_attributes, - unreachable_pub, - unused, - reason = "Checked elsewhere" -)] +#[allow(warnings, reason = "Checked elsewhere")] #[path = "src/compile/mod.rs"] mod compile; -#[allow( - clippy::allow_attributes, - unreachable_pub, - unused, - reason = "Checked elsewhere" -)] +#[allow(warnings, reason = "Checked elsewhere")] #[path = "src/types.rs"] mod types; @@ -67,7 +57,10 @@ fn write_shaders( shaders: &[(String, ShaderInfo)], ) -> Result<(), std::fmt::Error> { writeln!(buf, "mod generated {{")?; - writeln!(buf, " #[allow(clippy::wildcard_imports)]")?; + writeln!( + buf, + " #[expect(clippy::wildcard_imports, reason=\"Allows using Debug for codegen\")]" + )?; writeln!(buf, " use super::*;")?; writeln!(buf, " use BindType::*;")?; writeln!(buf, " pub const SHADERS: Shaders<'static> = Shaders {{")?; diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index 3e167546e..1cd94ce4c 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -32,17 +32,23 @@ #![allow(missing_docs, reason = "We have many as-yet undocumented items.")] #![expect( missing_debug_implementations, + clippy::exhaustive_enums, + reason = "Deferred" +)] +#![allow( elided_lifetimes_in_paths, + clippy::print_stdout, + clippy::print_stderr, single_use_lifetimes, unnameable_types, clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, - clippy::missing_assert_message, clippy::shadow_unrelated, + clippy::missing_assert_message, clippy::missing_panics_doc, - clippy::exhaustive_enums, + clippy::missing_errors_doc, clippy::todo, - reason = "Deferred" + reason = "Deferred, only apply in some feature sets so not expect" )] mod types; diff --git a/vello_shaders/src/types.rs b/vello_shaders/src/types.rs index 76bb235e7..a7a3ef905 100644 --- a/vello_shaders/src/types.rs +++ b/vello_shaders/src/types.rs @@ -50,7 +50,7 @@ pub mod msl { } impl fmt::Debug for BindingIndex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Self::Buffer(i) => write!(f, "msl::BindingIndex::Buffer({})", i), Self::Texture(i) => write!(f, "msl::BindingIndex::Texture({})", i), From 7b43d857c68528e419a0ec9dd89af98a8b6756d9 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:21:41 +0000 Subject: [PATCH 03/10] Workaround wildcard_imports --- vello_shaders/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vello_shaders/build.rs b/vello_shaders/build.rs index 62878670a..2f0f6d56e 100644 --- a/vello_shaders/build.rs +++ b/vello_shaders/build.rs @@ -59,7 +59,11 @@ fn write_shaders( writeln!(buf, "mod generated {{")?; writeln!( buf, - " #[expect(clippy::wildcard_imports, reason=\"Allows using Debug for codegen\")]" + " #![expect(clippy::allow_attributes, reason=\"Expect doesn't work with wildcard_imports\")]" + )?; + writeln!( + buf, + " #[allow(clippy::wildcard_imports, reason=\"Allows using Debug for codegen\")]" )?; writeln!(buf, " use super::*;")?; writeln!(buf, " use BindType::*;")?; From 43af5726f61798fa51908dcfb1fcdd25db454fdf Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:30:45 +0000 Subject: [PATCH 04/10] Update to lint set v3 --- Cargo.toml | 8 +++----- vello/src/lib.rs | 4 +++- vello_encoding/src/lib.rs | 4 +++- vello_shaders/src/lib.rs | 4 +++- vello_tests/src/lib.rs | 4 +++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d2c4e87f8..afd17cfae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,8 @@ license = "Apache-2.0 OR MIT" repository = "https://github.com/linebender/vello" [workspace.lints] -# LINEBENDER LINT SET - Cargo.toml - v2 + +# LINEBENDER LINT SET - Cargo.toml - v3 # See https://linebender.org/wiki/canonical-lints/ rust.keyword_idents_2024 = "forbid" rust.non_ascii_idents = "forbid" @@ -63,9 +64,7 @@ clippy.dbg_macro = "warn" clippy.debug_assert_with_mut_call = "warn" clippy.doc_markdown = "warn" clippy.exhaustive_enums = "warn" -# Break from the lint set due to https://github.com/rust-lang/rust/issues/133346#issuecomment-2503567552 -# and our use of clap. -clippy.fn_to_numeric_cast_any = "deny" +clippy.fn_to_numeric_cast_any = "warn" clippy.infinite_loop = "warn" clippy.large_include_file = "warn" clippy.large_stack_arrays = "warn" @@ -82,7 +81,6 @@ clippy.semicolon_if_nothing_returned = "warn" clippy.shadow_unrelated = "warn" clippy.should_panic_without_expect = "warn" clippy.todo = "warn" -clippy.trivially_copy_pass_by_ref = "warn" clippy.unseparated_literal_suffix = "warn" clippy.use_self = "warn" clippy.wildcard_imports = "warn" diff --git a/vello/src/lib.rs b/vello/src/lib.rs index 7a0d04dc5..e0be52817 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -81,12 +81,14 @@ //! //! See the [`examples/`](https://github.com/linebender/vello/tree/main/examples) folder to see how that code integrates with frameworks like winit. -// LINEBENDER LINT SET - lib.rs - v1 +// LINEBENDER LINT SET - lib.rs - v2 // See https://linebender.org/wiki/canonical-lints/ // These lints aren't included in Cargo.toml because they // shouldn't apply to examples and tests #![warn(unused_crate_dependencies)] #![warn(clippy::print_stdout, clippy::print_stderr)] +// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit. +#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))] // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] // The following lints are part of the Linebender standard set, diff --git a/vello_encoding/src/lib.rs b/vello_encoding/src/lib.rs index aa8cbed22..066b8eae3 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -3,12 +3,14 @@ //! Raw scene encoding. -// LINEBENDER LINT SET - lib.rs - v1 +// LINEBENDER LINT SET - lib.rs - v2 // See https://linebender.org/wiki/canonical-lints/ // These lints aren't included in Cargo.toml because they // shouldn't apply to examples and tests #![warn(unused_crate_dependencies)] #![warn(clippy::print_stdout, clippy::print_stderr)] +// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit. +#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))] // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] // The following lints are part of the Linebender standard set, diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index 1cd94ce4c..db652da8c 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -17,12 +17,14 @@ //! //! [Vello]: https://github.com/linebender/vello -// LINEBENDER LINT SET - lib.rs - v1 +// LINEBENDER LINT SET - lib.rs - v2 // See https://linebender.org/wiki/canonical-lints/ // These lints aren't included in Cargo.toml because they // shouldn't apply to examples and tests #![warn(unused_crate_dependencies)] #![warn(clippy::print_stdout, clippy::print_stderr)] +// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit. +#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))] // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] // The following lints are part of the Linebender standard set, diff --git a/vello_tests/src/lib.rs b/vello_tests/src/lib.rs index 61d87cd5f..d0acc17e6 100644 --- a/vello_tests/src/lib.rs +++ b/vello_tests/src/lib.rs @@ -3,12 +3,14 @@ //! Vello tests. -// LINEBENDER LINT SET - lib.rs - v1 +// LINEBENDER LINT SET - lib.rs - v2 // See https://linebender.org/wiki/canonical-lints/ // These lints aren't included in Cargo.toml because they // shouldn't apply to examples and tests #![warn(unused_crate_dependencies)] #![warn(clippy::print_stdout, clippy::print_stderr)] +// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit. +#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))] // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] // The following lints are part of the Linebender standard set, From a79604e4cf2e8e3974e0c1964b63166ce05d5ff7 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:36:34 +0000 Subject: [PATCH 05/10] Add exception for variant size differences --- vello_encoding/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vello_encoding/src/lib.rs b/vello_encoding/src/lib.rs index 066b8eae3..5ecaa0cc9 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -32,6 +32,8 @@ #![allow( unnameable_types, clippy::shadow_unrelated, + // Only applies on WASM? + variant_size_differences, clippy::exhaustive_enums, reason = "Deferred, only apply in some feature sets so not expect" )] From bf5f4becae3859da9cad1c7473f6651c558b395a Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:46:06 +0000 Subject: [PATCH 06/10] Fixup too-many-arguments --- Cargo.toml | 2 ++ examples/scenes/src/simple_text.rs | 4 ---- examples/scenes/src/test_scenes.rs | 4 ---- examples/with_winit/src/stats.rs | 4 ---- vello/src/debug/renderer.rs | 4 ---- vello/src/wgpu_engine.rs | 8 -------- vello_shaders/src/cpu.rs | 5 ----- 7 files changed, 2 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index afd17cfae..50f1f07aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,8 @@ rust.unused_macro_rules = "warn" rust.unused_qualifications = "warn" rust.variant_size_differences = "warn" +clippy.too_many_arguments = "allow" + clippy.allow_attributes = "warn" clippy.allow_attributes_without_reason = "warn" clippy.cast_possible_truncation = "warn" diff --git a/examples/scenes/src/simple_text.rs b/examples/scenes/src/simple_text.rs index 9fe417d47..1f3c4eae7 100644 --- a/examples/scenes/src/simple_text.rs +++ b/examples/scenes/src/simple_text.rs @@ -43,7 +43,6 @@ impl SimpleText { /// /// Note that Vello does support COLR emoji, but does not currently support /// any other forms of emoji. - #[allow(clippy::too_many_arguments)] pub fn add_colr_emoji_run<'a>( &mut self, scene: &mut Scene, @@ -75,7 +74,6 @@ impl SimpleText { /// not significantly increasing repository size. /// /// This will use a CBTF font, which Vello supports. - #[allow(clippy::too_many_arguments)] pub fn add_bitmap_emoji_run<'a>( &mut self, scene: &mut Scene, @@ -100,7 +98,6 @@ impl SimpleText { ); } - #[allow(clippy::too_many_arguments)] pub fn add_run<'a>( &mut self, scene: &mut Scene, @@ -125,7 +122,6 @@ impl SimpleText { ); } - #[allow(clippy::too_many_arguments)] pub fn add_var_run<'a>( &mut self, scene: &mut Scene, diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index 9e3e60542..a2a02491a 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs @@ -882,10 +882,6 @@ mod impls { params.resolution = Some((1200.0, 1200.0).into()); } - #[expect( - clippy::too_many_arguments, - reason = "This function is internal, so the argument count doesn't cause issues for consumers." - )] pub(super) fn two_point_radial(scene: &mut Scene, _params: &mut SceneParams) { pub(super) fn make( scene: &mut Scene, diff --git a/examples/with_winit/src/stats.rs b/examples/with_winit/src/stats.rs index 687803e57..e9f9c6b4f 100644 --- a/examples/with_winit/src/stats.rs +++ b/examples/with_winit/src/stats.rs @@ -25,10 +25,6 @@ pub struct Snapshot { } impl Snapshot { - #[expect( - clippy::too_many_arguments, - reason = "This function is internal, so the argument count doesn't cause issues for consumers." - )] pub fn draw_layer<'a, T>( &self, scene: &mut Scene, diff --git a/vello/src/debug/renderer.rs b/vello/src/debug/renderer.rs index 0d50430d3..6de15991b 100644 --- a/vello/src/debug/renderer.rs +++ b/vello/src/debug/renderer.rs @@ -213,10 +213,6 @@ impl DebugRenderer { } } - #[expect( - clippy::too_many_arguments, - reason = "This function is internal, so the argument count doesn't cause issues for consumers." - )] pub fn render( &self, recording: &mut Recording, diff --git a/vello/src/wgpu_engine.rs b/vello/src/wgpu_engine.rs index f00974ed7..6346b01de 100644 --- a/vello/src/wgpu_engine.rs +++ b/vello/src/wgpu_engine.rs @@ -308,10 +308,6 @@ impl WgpuEngine { }) } - #[expect( - clippy::too_many_arguments, - reason = "This function is internal, so the argument count doesn't cause issues for consumers." - )] pub fn add_render_shader( &mut self, device: &Device, @@ -1056,10 +1052,6 @@ impl<'a> TransientBindMap<'a> { .expect("texture not materialized") } - #[expect( - clippy::too_many_arguments, - reason = "This function is internal, so the argument count doesn't cause issues for consumers." - )] fn create_bind_group( &mut self, bind_map: &mut BindMap, diff --git a/vello_shaders/src/cpu.rs b/vello_shaders/src/cpu.rs index 89be76c1b..443f7f66f 100644 --- a/vello_shaders/src/cpu.rs +++ b/vello_shaders/src/cpu.rs @@ -7,11 +7,6 @@ //! a full CPU fallback as an alternative to GPU shaders is not provided. // Allow un-idiomatic Rust to more closely match shaders -#![expect( - clippy::needless_range_loop, - clippy::too_many_arguments, - reason = "Keeps code easily comparable to GPU shaders" -)] mod backdrop; mod bbox_clear; From a7b8d6317cd8c724342a5f1c84f8c26831cab0a9 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:55:12 +0000 Subject: [PATCH 07/10] Allow `needless_range_loop` Not sure why this was passing before? --- vello_shaders/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index db652da8c..ae46c05a3 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -39,17 +39,18 @@ )] #![allow( elided_lifetimes_in_paths, - clippy::print_stdout, - clippy::print_stderr, single_use_lifetimes, unnameable_types, - clippy::unseparated_literal_suffix, clippy::cast_possible_truncation, - clippy::shadow_unrelated, clippy::missing_assert_message, - clippy::missing_panics_doc, clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::needless_range_loop, + clippy::print_stderr, + clippy::print_stdout, + clippy::shadow_unrelated, clippy::todo, + clippy::unseparated_literal_suffix, reason = "Deferred, only apply in some feature sets so not expect" )] From 582a0902bc1ba83b9748976e240e4941356ed757 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:56:08 +0000 Subject: [PATCH 08/10] Part revert prior two commits --- vello_shaders/src/cpu.rs | 4 ++++ vello_shaders/src/lib.rs | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vello_shaders/src/cpu.rs b/vello_shaders/src/cpu.rs index 443f7f66f..ae2977166 100644 --- a/vello_shaders/src/cpu.rs +++ b/vello_shaders/src/cpu.rs @@ -7,6 +7,10 @@ //! a full CPU fallback as an alternative to GPU shaders is not provided. // Allow un-idiomatic Rust to more closely match shaders +#![expect( + clippy::needless_range_loop, + reason = "Keeps code easily comparable to GPU shaders" +)] mod backdrop; mod bbox_clear; diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index ae46c05a3..60893ec33 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -45,7 +45,6 @@ clippy::missing_assert_message, clippy::missing_errors_doc, clippy::missing_panics_doc, - clippy::needless_range_loop, clippy::print_stderr, clippy::print_stdout, clippy::shadow_unrelated, From 1ff851b34c8833435207c1f592adfb310b9f2338 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:06:55 +0000 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Kaur Kuut --- vello/src/lib.rs | 16 +--------------- vello_encoding/src/lib.rs | 2 +- vello_shaders/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/vello/src/lib.rs b/vello/src/lib.rs index e0be52817..cdfc7c90e 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -94,7 +94,7 @@ // The following lints are part of the Linebender standard set, // but resolving them has been deferred for now. // Feel free to send a PR that solves one or more of these. -// Allow because of: https://github.com/rust-lang/rust/pull/130025 +// Need to allow instead of expect until Rust 1.83 https://github.com/rust-lang/rust/pull/130025 #![allow(missing_docs, reason = "We have many as-yet undocumented items.")] #![expect( missing_debug_implementations, @@ -114,23 +114,9 @@ reason = "Deferred" )] #![allow( - // missing_debug_implementations, - // elided_lifetimes_in_paths, - // single_use_lifetimes, - // unnameable_types, - // unreachable_pub, - // clippy::return_self_not_must_use, - // clippy::cast_possible_truncation, - // clippy::missing_assert_message, - // clippy::shadow_unrelated, - // clippy::missing_panics_doc, clippy::missing_errors_doc, - // clippy::exhaustive_enums, clippy::todo, - // clippy::print_stderr, clippy::partial_pub_fields, - // clippy::use_self, - // clippy::match_same_arms, reason = "Deferred, only apply in some feature sets so not expect" )] diff --git a/vello_encoding/src/lib.rs b/vello_encoding/src/lib.rs index 5ecaa0cc9..5966a3620 100644 --- a/vello_encoding/src/lib.rs +++ b/vello_encoding/src/lib.rs @@ -16,7 +16,7 @@ // The following lints are part of the Linebender standard set, // but resolving them has been deferred for now. // Feel free to send a PR that solves one or more of these. -// Allow because of: https://github.com/rust-lang/rust/pull/130025 +// Need to allow instead of expect until Rust 1.83 https://github.com/rust-lang/rust/pull/130025 #![allow(missing_docs, reason = "We have many as-yet undocumented items.")] #![expect( missing_debug_implementations, diff --git a/vello_shaders/src/lib.rs b/vello_shaders/src/lib.rs index 60893ec33..54c063491 100644 --- a/vello_shaders/src/lib.rs +++ b/vello_shaders/src/lib.rs @@ -30,7 +30,7 @@ // The following lints are part of the Linebender standard set, // but resolving them has been deferred for now. // Feel free to send a PR that solves one or more of these. -// Allow because of: https://github.com/rust-lang/rust/pull/130025 +// Need to allow instead of expect until Rust 1.83 https://github.com/rust-lang/rust/pull/130025 #![allow(missing_docs, reason = "We have many as-yet undocumented items.")] #![expect( missing_debug_implementations, From 63c1f35b595514d089021da61a4e118a2801c2b3 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:09:38 +0000 Subject: [PATCH 10/10] Use shadowing for `maybe_features` override --- vello/src/util.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/vello/src/util.rs b/vello/src/util.rs index beb0efe4e..b33c225a3 100644 --- a/vello/src/util.rs +++ b/vello/src/util.rs @@ -140,18 +140,10 @@ impl RenderContext { .await?; let features = adapter.features(); let limits = Limits::default(); - #[cfg_attr( - not(feature = "wgpu-profiler"), - expect( - unused_mut, - reason = "Mutation is only expected with the wgpu-profiler feature" - ) - )] - let mut maybe_features = wgpu::Features::CLEAR_TEXTURE; + let maybe_features = wgpu::Features::CLEAR_TEXTURE; #[cfg(feature = "wgpu-profiler")] - { - maybe_features |= wgpu_profiler::GpuProfiler::ALL_WGPU_TIMER_FEATURES; - }; + let maybe_features = maybe_features | wgpu_profiler::GpuProfiler::ALL_WGPU_TIMER_FEATURES; + let (device, queue) = adapter .request_device( &wgpu::DeviceDescriptor {