diff --git a/examples/scenes/src/lib.rs b/examples/scenes/src/lib.rs index b6870fe2..322c773f 100644 --- a/examples/scenes/src/lib.rs +++ b/examples/scenes/src/lib.rs @@ -19,7 +19,6 @@ clippy::missing_panics_doc, clippy::missing_errors_doc, clippy::partial_pub_fields, - clippy::use_self, clippy::match_same_arms, clippy::allow_attributes_without_reason, clippy::allow_attributes diff --git a/examples/scenes/src/mmark.rs b/examples/scenes/src/mmark.rs index 45b419ac..c0b6590a 100644 --- a/examples/scenes/src/mmark.rs +++ b/examples/scenes/src/mmark.rs @@ -41,8 +41,8 @@ struct Element { struct GridPoint(i64, i64); impl MMark { - pub fn new(n: usize) -> MMark { - let mut result = MMark { elements: vec![] }; + pub fn new(n: usize) -> Self { + let mut result = Self { elements: vec![] }; result.resize(n); result } @@ -128,7 +128,7 @@ const COLORS: &[Color] = &[ ]; impl Element { - fn new_rand(last: GridPoint) -> Element { + fn new_rand(last: GridPoint) -> Self { let mut rng = rand::thread_rng(); let seg_type = rng.gen_range(0..4); let next = GridPoint::random_point(last); @@ -163,7 +163,7 @@ impl Element { let color = *COLORS.choose(&mut rng).unwrap(); let width = rng.r#gen::().powi(5) * 20.0 + 1.0; let is_split = rng.r#gen(); - Element { + Self { seg, color, width, @@ -176,7 +176,7 @@ impl Element { const OFFSETS: &[(i64, i64)] = &[(-4, 0), (2, 0), (1, -2), (1, 2)]; impl GridPoint { - fn random_point(last: GridPoint) -> GridPoint { + fn random_point(last: Self) -> Self { let mut rng = rand::thread_rng(); let offset = OFFSETS.choose(&mut rng).unwrap(); @@ -188,7 +188,7 @@ impl GridPoint { if !(0..=GRID_HEIGHT).contains(&y) { y -= offset.1 * 2; } - GridPoint(x, y) + Self(x, y) } fn coordinate(self) -> Point { diff --git a/examples/scenes/src/pico_svg.rs b/examples/scenes/src/pico_svg.rs index 0765e9db..d83601e3 100644 --- a/examples/scenes/src/pico_svg.rs +++ b/examples/scenes/src/pico_svg.rs @@ -43,7 +43,7 @@ struct Parser { } impl PicoSvg { - pub fn load(xml_string: &str, scale: f64) -> Result> { + pub fn load(xml_string: &str, scale: f64) -> Result> { let doc = Document::parse(xml_string)?; let root = doc.root_element(); let mut parser = Parser::new(scale); @@ -114,7 +114,7 @@ impl PicoSvg { affine: transform, children: items, }); - Ok(PicoSvg { + Ok(Self { items: vec![root_group], size, }) @@ -127,8 +127,8 @@ struct RecursiveProperties { } impl Parser { - fn new(scale: f64) -> Parser { - Parser { scale } + fn new(scale: f64) -> Self { + Self { scale } } fn rec_parse( diff --git a/vello/src/debug.rs b/vello/src/debug.rs index 918fd0dd..9a389a42 100644 --- a/vello/src/debug.rs +++ b/vello/src/debug.rs @@ -46,15 +46,15 @@ impl Debug for DebugLayers { impl DebugLayers { /// Visualize the bounding box of every path. /// Requires the `debug_layers` feature. - pub const BOUNDING_BOXES: DebugLayers = DebugLayers(1 << 0); + pub const BOUNDING_BOXES: Self = Self(1 << 0); /// Visualize the post-flattening line segments using line primitives. /// Requires the `debug_layers` feature. - pub const LINESOUP_SEGMENTS: DebugLayers = DebugLayers(1 << 1); + pub const LINESOUP_SEGMENTS: Self = Self(1 << 1); /// Visualize the post-flattening line endpoints. /// Requires the `debug_layers` feature. - pub const LINESOUP_POINTS: DebugLayers = DebugLayers(1 << 2); + pub const LINESOUP_POINTS: Self = Self(1 << 2); /// Enable validation of internal buffer contents and visualize errors. Validation tests are /// run on the CPU and require buffer contents to be read-back. @@ -66,7 +66,7 @@ impl DebugLayers { /// as red circles and logged to stderr. /// /// Requires the `debug_layers` feature. - pub const VALIDATION: DebugLayers = DebugLayers(1 << 3); + pub const VALIDATION: Self = Self(1 << 3); /// Construct a `DebugLayers` from the raw bits. pub const fn from_bits(bits: u8) -> Self { @@ -100,12 +100,12 @@ impl DebugLayers { } /// Determine whether `self` is a superset of `mask`. - pub const fn contains(self, mask: DebugLayers) -> bool { + pub const fn contains(self, mask: Self) -> bool { self.0 & mask.0 == mask.0 } /// Toggle the value of the layers specified in mask. - pub fn toggle(&mut self, mask: DebugLayers) { + pub fn toggle(&mut self, mask: Self) { self.0 ^= mask.0; } } diff --git a/vello/src/lib.rs b/vello/src/lib.rs index ce019056..8438347d 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -109,7 +109,6 @@ clippy::missing_panics_doc, clippy::exhaustive_enums, clippy::print_stderr, - clippy::use_self, clippy::match_same_arms, reason = "Deferred" )] diff --git a/vello/src/recording.rs b/vello/src/recording.rs index 0edebab7..a9140592 100644 --- a/vello/src/recording.rs +++ b/vello/src/recording.rs @@ -13,10 +13,10 @@ pub struct ShaderId(pub usize); pub struct ResourceId(pub NonZeroU64); impl ResourceId { - pub fn next() -> ResourceId { + pub fn next() -> Self { // We initialize with 1 so that the conversion below succeeds static ID_COUNTER: AtomicU64 = AtomicU64::new(1); - ResourceId(NonZeroU64::new(ID_COUNTER.fetch_add(1, Ordering::Relaxed)).unwrap()) + Self(NonZeroU64::new(ID_COUNTER.fetch_add(1, Ordering::Relaxed)).unwrap()) } } @@ -233,7 +233,7 @@ impl BufferProxy { pub fn new(size: u64, name: &'static str) -> Self { let id = ResourceId::next(); debug_assert!(size > 0); - BufferProxy { id, size, name } + Self { id, size, name } } } @@ -259,7 +259,7 @@ impl ImageFormat { impl ImageProxy { pub fn new(width: u32, height: u32, format: ImageFormat) -> Self { let id = ResourceId::next(); - ImageProxy { + Self { width, height, format, diff --git a/vello/src/render.rs b/vello/src/render.rs index 521554b4..72e36ef8 100644 --- a/vello/src/render.rs +++ b/vello/src/render.rs @@ -109,7 +109,7 @@ impl Default for Render { impl Render { pub fn new() -> Self { - Render { + Self { fine_wg_count: None, fine_resources: None, mask_buf: None, diff --git a/vello/src/scene.rs b/vello/src/scene.rs index aba8ab68..01332245 100644 --- a/vello/src/scene.rs +++ b/vello/src/scene.rs @@ -310,7 +310,7 @@ impl Scene { /// /// The given transform is applied to every transform in the child. /// This is an O(N) operation. - pub fn append(&mut self, other: &Scene, transform: Option) { + pub fn append(&mut self, other: &Self, transform: Option) { let t = transform.as_ref().map(Transform::from_kurbo); self.encoding.append(&other.encoding, &t); #[cfg(feature = "bump_estimate")] diff --git a/vello/src/wgpu_engine.rs b/vello/src/wgpu_engine.rs index c1d9cb2a..640b3580 100644 --- a/vello/src/wgpu_engine.rs +++ b/vello/src/wgpu_engine.rs @@ -141,7 +141,7 @@ enum TransientBuf<'a> { } impl WgpuEngine { - pub fn new(use_cpu: bool) -> WgpuEngine { + pub fn new(use_cpu: bool) -> Self { Self { use_cpu, ..Default::default() diff --git a/vello_tests/src/lib.rs b/vello_tests/src/lib.rs index 30a1151f..ddd2312e 100644 --- a/vello_tests/src/lib.rs +++ b/vello_tests/src/lib.rs @@ -26,7 +26,6 @@ clippy::missing_panics_doc, clippy::missing_errors_doc, clippy::exhaustive_enums, - clippy::use_self, clippy::print_stderr, clippy::print_stdout, clippy::allow_attributes_without_reason @@ -68,7 +67,7 @@ pub struct TestParams { impl TestParams { pub fn new(name: impl Into, width: u32, height: u32) -> Self { - TestParams { + Self { width, height, base_color: None, diff --git a/vello_tests/src/snapshot.rs b/vello_tests/src/snapshot.rs index 17723991..0e65e9a2 100644 --- a/vello_tests/src/snapshot.rs +++ b/vello_tests/src/snapshot.rs @@ -123,8 +123,8 @@ pub enum SnapshotDirectory { impl SnapshotDirectory { fn max_size_in_bytes(self) -> u64 { match self { - SnapshotDirectory::Smoke => 4 * 1024, /* 4KiB */ - SnapshotDirectory::Lfs => 128 * 1024, /* 128KiB */ + Self::Smoke => 4 * 1024, /* 4KiB */ + Self::Lfs => 128 * 1024, /* 128KiB */ } } }