Skip to content

Commit

Permalink
Fix and un-allow elided_lifetimes_in_paths lints
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys committed Dec 18, 2024
1 parent 5f065d7 commit e8d5c1f
Show file tree
Hide file tree
Showing 31 changed files with 72 additions and 73 deletions.
7 changes: 3 additions & 4 deletions examples/scenes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Feel free to send a PR that solves one or more of these.
#![allow(
missing_debug_implementations,
elided_lifetimes_in_paths,
single_use_lifetimes,
unreachable_pub,
missing_docs,
Expand Down Expand Up @@ -68,11 +67,11 @@ pub struct ExampleScene {
}

pub trait TestScene {
fn render(&mut self, scene: &mut Scene, params: &mut SceneParams);
fn render(&mut self, scene: &mut Scene, params: &mut SceneParams<'_>);
}

impl<F: FnMut(&mut Scene, &mut SceneParams)> TestScene for F {
fn render(&mut self, scene: &mut Scene, params: &mut SceneParams) {
impl<F: FnMut(&mut Scene, &mut SceneParams<'_>)> TestScene for F {
fn render(&mut self, scene: &mut Scene, params: &mut SceneParams<'_>) {
self(scene, params);
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/scenes/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn render_svg_rec(items: &[crate::pico_svg::Item]) -> Scene {
pub fn svg_function_of<R: AsRef<str>>(
name: String,
contents: impl FnOnce() -> R + Send + 'static,
) -> impl FnMut(&mut Scene, &mut SceneParams) {
) -> impl FnMut(&mut Scene, &mut SceneParams<'_>) {
fn render_svg_contents(name: &str, contents: &str) -> (Scene, Vec2) {
use crate::pico_svg::*;
let start = Instant::now();
Expand Down
50 changes: 25 additions & 25 deletions examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod impls {

const FLOWER_IMAGE: &[u8] = include_bytes!("../../assets/splash-flower.jpg");

pub(super) fn emoji(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn emoji(scene: &mut Scene, params: &mut SceneParams<'_>) {
let text_size = 120. + 20. * (params.time * 2.).sin() as f32;
let s = "🎉🤠✅";
params.text.add_colr_emoji_run(
Expand All @@ -123,7 +123,7 @@ mod impls {
);
}

pub(super) fn funky_paths(scene: &mut Scene, _: &mut SceneParams) {
pub(super) fn funky_paths(scene: &mut Scene, _: &mut SceneParams<'_>) {
use PathEl::*;
let missing_movetos = [
MoveTo((0., 0.).into()),
Expand Down Expand Up @@ -165,7 +165,7 @@ mod impls {
);
}

pub(super) fn stroke_styles(transform: Affine) -> impl FnMut(&mut Scene, &mut SceneParams) {
pub(super) fn stroke_styles(transform: Affine) -> impl FnMut(&mut Scene, &mut SceneParams<'_>) {
use PathEl::*;
move |scene, params| {
let colors = [
Expand Down Expand Up @@ -343,7 +343,7 @@ mod impls {

// This test has been adapted from Skia's "trickycubicstrokes" GM slide which can be found at
// `github.com/google/skia/blob/0d4d11451c4f4e184305cbdbd67f6b3edfa4b0e3/gm/trickycubicstrokes.cpp`
pub(super) fn tricky_strokes(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn tricky_strokes(scene: &mut Scene, params: &mut SceneParams<'_>) {
use PathEl::*;
let colors = [
Color::from_rgba8(140, 181, 236, 255),
Expand Down Expand Up @@ -529,7 +529,7 @@ mod impls {
));
}

pub(super) fn fill_types(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn fill_types(scene: &mut Scene, params: &mut SceneParams<'_>) {
use PathEl::*;
params.resolution = Some((1400., 700.).into());
let rect = Rect::from_origin_size(Point::new(0., 0.), (500., 500.));
Expand Down Expand Up @@ -602,14 +602,14 @@ mod impls {
}
}

pub(super) fn cardioid_and_friends(scene: &mut Scene, _: &mut SceneParams) {
pub(super) fn cardioid_and_friends(scene: &mut Scene, _: &mut SceneParams<'_>) {
render_cardioid(scene);
render_clip_test(scene);
render_alpha_test(scene);
//render_tiger(scene, false);
}

pub(super) fn longpathdash(cap: Cap) -> impl FnMut(&mut Scene, &mut SceneParams) {
pub(super) fn longpathdash(cap: Cap) -> impl FnMut(&mut Scene, &mut SceneParams<'_>) {
use PathEl::*;
move |scene, _| {
let mut path = BezPath::new();
Expand Down Expand Up @@ -653,7 +653,7 @@ mod impls {
}
}

pub(super) fn animated_text(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn animated_text(scene: &mut Scene, params: &mut SceneParams<'_>) {
// Uses the static array address as a cache key for expedience. Real code
// should use a better strategy.
let piet_logo = params
Expand Down Expand Up @@ -770,7 +770,7 @@ mod impls {
);
}

pub(super) fn brush_transform(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn brush_transform(scene: &mut Scene, params: &mut SceneParams<'_>) {
let th = params.time;
let linear = Gradient::new_linear((0.0, 0.0), (0.0, 200.0)).with_stops([
palette::css::RED,
Expand Down Expand Up @@ -804,7 +804,7 @@ mod impls {
);
}

pub(super) fn gradient_extend(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn gradient_extend(scene: &mut Scene, params: &mut SceneParams<'_>) {
enum Kind {
Linear,
Radial,
Expand Down Expand Up @@ -871,7 +871,7 @@ mod impls {
params.resolution = Some((1200.0, 1200.0).into());
}

pub(super) fn two_point_radial(scene: &mut Scene, _params: &mut SceneParams) {
pub(super) fn two_point_radial(scene: &mut Scene, _params: &mut SceneParams<'_>) {
pub(super) fn make(
scene: &mut Scene,
x0: f64,
Expand Down Expand Up @@ -1039,7 +1039,7 @@ mod impls {
}
}

pub(super) fn blend_grid(scene: &mut Scene, _: &mut SceneParams) {
pub(super) fn blend_grid(scene: &mut Scene, _: &mut SceneParams<'_>) {
const BLEND_MODES: &[Mix] = &[
Mix::Normal,
Mix::Multiply,
Expand Down Expand Up @@ -1067,7 +1067,7 @@ mod impls {
}
}

pub(super) fn deep_blend(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn deep_blend(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1000., 1000.));
let main_rect = Rect::from_origin_size((10., 10.), (900., 900.));
scene.fill(
Expand Down Expand Up @@ -1103,7 +1103,7 @@ mod impls {
}
}

pub(super) fn many_clips(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn many_clips(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1000., 1000.));
let mut rng = StdRng::seed_from_u64(42);
let mut base_tri = BezPath::new();
Expand Down Expand Up @@ -1270,7 +1270,7 @@ mod impls {
fragment
}

pub(super) fn conflation_artifacts(scene: &mut Scene, _: &mut SceneParams) {
pub(super) fn conflation_artifacts(scene: &mut Scene, _: &mut SceneParams<'_>) {
use PathEl::*;
const N: f64 = 50.0;
const S: f64 = 4.0;
Expand Down Expand Up @@ -1359,7 +1359,7 @@ mod impls {
);
}

pub(super) fn labyrinth(scene: &mut Scene, _: &mut SceneParams) {
pub(super) fn labyrinth(scene: &mut Scene, _: &mut SceneParams<'_>) {
use PathEl::*;

let rows: &[[u8; 12]] = &[
Expand Down Expand Up @@ -1436,7 +1436,7 @@ mod impls {
);
}

pub(super) fn robust_paths(scene: &mut Scene, _: &mut SceneParams) {
pub(super) fn robust_paths(scene: &mut Scene, _: &mut SceneParams<'_>) {
let mut path = BezPath::new();
path.move_to((16.0, 16.0));
path.line_to((32.0, 16.0));
Expand Down Expand Up @@ -1519,7 +1519,7 @@ mod impls {
);
}

pub(super) fn base_color_test(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn base_color_test(scene: &mut Scene, params: &mut SceneParams<'_>) {
// Cycle through the hue value every 5 seconds (t % 5) * 360/5
let color = AlphaColor::<Lch>::new([80., 80., (params.time % 5.) as f32 * 72., 1.]);
params.base_color = Some(color.convert());
Expand All @@ -1534,7 +1534,7 @@ mod impls {
);
}

pub(super) fn clip_test(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn clip_test(scene: &mut Scene, params: &mut SceneParams<'_>) {
let clip = {
const X0: f64 = 50.0;
const Y0: f64 = 0.0;
Expand Down Expand Up @@ -1639,7 +1639,7 @@ mod impls {
]
}

pub(super) fn many_draw_objects(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn many_draw_objects(scene: &mut Scene, params: &mut SceneParams<'_>) {
const N_WIDE: usize = 300;
const N_HIGH: usize = 300;
const SCENE_WIDTH: f64 = 2000.0;
Expand All @@ -1661,7 +1661,7 @@ mod impls {
}
}

pub(super) fn splash_screen(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn splash_screen(scene: &mut Scene, params: &mut SceneParams<'_>) {
let strings = [
"Vello test",
" Arrow keys: switch scenes",
Expand All @@ -1686,7 +1686,7 @@ mod impls {
}
}

pub(super) fn splash_with_tiger() -> impl FnMut(&mut Scene, &mut SceneParams) {
pub(super) fn splash_with_tiger() -> impl FnMut(&mut Scene, &mut SceneParams<'_>) {
let contents = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../assets/Ghostscript_Tiger.svg"
Expand All @@ -1699,7 +1699,7 @@ mod impls {
}
}

pub(super) fn blurred_rounded_rect(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn blurred_rounded_rect(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1200., 1200.));
params.base_color = Some(palette::css::WHITE);

Expand Down Expand Up @@ -1764,7 +1764,7 @@ mod impls {
);
}

pub(super) fn image_sampling(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn image_sampling(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1100., 1100.));
params.base_color = Some(palette::css::WHITE);
let mut blob: Vec<u8> = Vec::new();
Expand Down Expand Up @@ -1807,7 +1807,7 @@ mod impls {
);
}

pub(super) fn image_extend_modes(scene: &mut Scene, params: &mut SceneParams) {
pub(super) fn image_extend_modes(scene: &mut Scene, params: &mut SceneParams<'_>) {
params.resolution = Some(Vec2::new(1500., 1500.));
params.base_color = Some(palette::css::WHITE);
let mut blob: Vec<u8> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion vello/src/debug/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl DebugRenderer {
captured: &CapturedBuffers,
bump: &BumpAllocators,
params: &RenderParams,
downloads: &DebugDownloads,
downloads: &DebugDownloads<'_>,
layers: DebugLayers,
) {
if layers.is_empty() {
Expand Down
1 change: 0 additions & 1 deletion vello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
#![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,
Expand Down
4 changes: 2 additions & 2 deletions vello/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl Scene {
}

/// Returns a builder for encoding a glyph run.
pub fn draw_glyphs(&mut self, font: &Font) -> DrawGlyphs {
pub fn draw_glyphs(&mut self, font: &Font) -> DrawGlyphs<'_> {
// TODO: Integrate `BumpEstimator` with the glyph cache.
DrawGlyphs::new(self, font)
}
Expand Down Expand Up @@ -931,7 +931,7 @@ fn conv_skrifa_transform(transform: skrifa::color::Transform) -> Transform {
}

fn conv_brush(
brush: skrifa::color::Brush,
brush: skrifa::color::Brush<'_>,
cpal: &Cpal<'_>,
foreground_brush: BrushRef<'_>,
) -> Brush {
Expand Down
10 changes: 7 additions & 3 deletions vello/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,22 @@ impl RenderContext {
}

/// Resizes the surface to the new dimensions.
pub fn resize_surface(&self, surface: &mut RenderSurface, width: u32, height: u32) {
pub fn resize_surface(&self, surface: &mut RenderSurface<'_>, width: u32, height: u32) {
surface.config.width = width;
surface.config.height = height;
self.configure_surface(surface);
}

pub fn set_present_mode(&self, surface: &mut RenderSurface, present_mode: wgpu::PresentMode) {
pub fn set_present_mode(
&self,
surface: &mut RenderSurface<'_>,
present_mode: wgpu::PresentMode,
) {
surface.config.present_mode = present_mode;
self.configure_surface(surface);
}

fn configure_surface(&self, surface: &RenderSurface) {
fn configure_surface(&self, surface: &RenderSurface<'_>) {
let device = &self.devices[surface.dev_id].device;
surface.surface.configure(device, &surface.config);
}
Expand Down
16 changes: 8 additions & 8 deletions vello/src/wgpu_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ struct WgpuShader {
}

pub(crate) enum CpuShaderType {
Present(fn(u32, &[CpuBinding])),
Present(fn(u32, &[CpuBinding<'_>])),
Missing,
Skipped,
}

struct CpuShader {
shader: fn(u32, &[CpuBinding]),
shader: fn(u32, &[CpuBinding<'_>]),
}

enum ShaderKind<'a> {
Expand All @@ -76,7 +76,7 @@ struct Shader {
}

impl Shader {
fn select(&self) -> ShaderKind {
fn select(&self) -> ShaderKind<'_> {
if let Some(cpu) = self.cpu.as_ref() {
ShaderKind::Cpu(cpu)
} else if let Some(wgpu) = self.wgpu.as_ref() {
Expand Down Expand Up @@ -309,7 +309,7 @@ impl WgpuEngine {
fragment_main: &'static str,
topology: wgpu::PrimitiveTopology,
color_attachment: wgpu::ColorTargetState,
vertex_buffer: Option<wgpu::VertexBufferLayout>,
vertex_buffer: Option<wgpu::VertexBufferLayout<'_>>,
bind_layout: &[(BindType, wgpu::ShaderStages)],
) -> ShaderId {
let entries = Self::create_bind_group_layout_entries(bind_layout.iter().copied());
Expand Down Expand Up @@ -371,7 +371,7 @@ impl WgpuEngine {
device: &Device,
queue: &Queue,
recording: &Recording,
external_resources: &[ExternalResource],
external_resources: &[ExternalResource<'_>],
label: &'static str,
#[cfg(feature = "wgpu-profiler")] profiler: &mut wgpu_profiler::GpuProfiler,
) -> Result<()> {
Expand Down Expand Up @@ -859,7 +859,7 @@ impl BindMap {
/// Get a CPU buffer.
///
/// Panics if buffer is not present or is on GPU.
fn get_cpu_buf(&self, id: ResourceId) -> CpuBinding {
fn get_cpu_buf(&self, id: ResourceId) -> CpuBinding<'_> {
match &self.buf_map[&id].buffer {
MaterializedBuffer::Cpu(b) => CpuBinding::BufferRW(b),
_ => panic!("getting cpu buffer, but it's on gpu"),
Expand Down Expand Up @@ -993,7 +993,7 @@ impl BindMapBuffer {

impl<'a> TransientBindMap<'a> {
/// Create new transient bind map, seeded from external resources
fn new(external_resources: &'a [ExternalResource]) -> Self {
fn new(external_resources: &'a [ExternalResource<'_>]) -> Self {
let mut bufs = HashMap::default();
let mut images = HashMap::default();
for resource in external_resources {
Expand Down Expand Up @@ -1167,7 +1167,7 @@ impl<'a> TransientBindMap<'a> {
&self,
bind_map: &'a mut BindMap,
bindings: &[ResourceProxy],
) -> Vec<CpuBinding> {
) -> Vec<CpuBinding<'_>> {
// First pass is mutable; create buffers as needed
for resource in bindings {
match resource {
Expand Down
2 changes: 1 addition & 1 deletion vello_encoding/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Encoding {

/// Returns an encoder for encoding a path. If `is_fill` is true, all subpaths will
/// be automatically closed.
pub fn encode_path(&mut self, is_fill: bool) -> PathEncoder {
pub fn encode_path(&mut self, is_fill: bool) -> PathEncoder<'_> {
PathEncoder::new(
&mut self.path_tags,
&mut self.path_data,
Expand Down
Loading

0 comments on commit e8d5c1f

Please sign in to comment.