diff --git a/examples/vello_editor/src/main.rs b/examples/vello_editor/src/main.rs index afe93c6e..60e6c448 100644 --- a/examples/vello_editor/src/main.rs +++ b/examples/vello_editor/src/main.rs @@ -1,7 +1,6 @@ // Copyright 2024 the Parley Authors // SPDX-License-Identifier: Apache-2.0 OR MIT -#![allow(elided_lifetimes_in_paths)] #![allow(missing_debug_implementations)] #![allow(missing_docs)] #![allow(unreachable_pub)] @@ -364,7 +363,7 @@ fn create_winit_window(event_loop: &ActiveEventLoop) -> Arc { } /// Helper function that creates a vello `Renderer` for a given `RenderContext` and `RenderSurface` -fn create_vello_renderer(render_cx: &RenderContext, surface: &RenderSurface) -> Renderer { +fn create_vello_renderer(render_cx: &RenderContext, surface: &RenderSurface<'_>) -> Renderer { Renderer::new( &render_cx.devices[surface.dev_id].device, RendererOptions { diff --git a/fontique/src/attributes.rs b/fontique/src/attributes.rs index d57768e5..57914f87 100644 --- a/fontique/src/attributes.rs +++ b/fontique/src/attributes.rs @@ -214,7 +214,7 @@ impl FontStretch { } impl fmt::Display for FontStretch { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let value = self.0 * 1000.0; if value.fract() == 0.0 { let keyword = match value as i32 { @@ -376,7 +376,7 @@ impl Default for FontWeight { } impl fmt::Display for FontWeight { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let value = self.0; if value.fract() == 0.0 { let keyword = match value as i32 { @@ -480,7 +480,7 @@ impl FontStyle { } impl fmt::Display for FontStyle { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let value = match self { Self::Normal => "normal", Self::Italic => "italic", diff --git a/fontique/src/backend/android.rs b/fontique/src/backend/android.rs index 0f4c2c0f..becb28e6 100644 --- a/fontique/src/backend/android.rs +++ b/fontique/src/backend/android.rs @@ -101,15 +101,20 @@ impl SystemFonts { .attribute("lang") .map(|s| s.split(',').collect::>()) { - let (_has_for, hasnt_for): (Vec, Vec) = child + let (_has_for, hasnt_for): ( + Vec>, + Vec>, + ) = child .children() .partition(|c| c.attribute("fallbackFor").is_some()); { // general fallback families - let (ps_named, _ps_unnamed): (Vec, Vec) = - hasnt_for.iter().partition(|c| { - c.attribute("postScriptName").is_some() - }); + let (ps_named, _ps_unnamed): ( + Vec>, + Vec>, + ) = hasnt_for + .iter() + .partition(|c| c.attribute("postScriptName").is_some()); if let Some(family) = ps_named.iter().find_map(|x| { postscript_names diff --git a/fontique/src/backend/fontconfig/cache.rs b/fontique/src/backend/fontconfig/cache.rs index 79e13d33..71be711a 100644 --- a/fontique/src/backend/fontconfig/cache.rs +++ b/fontique/src/backend/fontconfig/cache.rs @@ -63,7 +63,7 @@ pub fn parse_caches(paths: &[PathBuf], mut f: impl FnMut(&CachedFont)) { } fn parse_font( - pattern: &Pattern, + pattern: &Pattern<'_>, name_free_list: &mut Vec, font: &mut CachedFont, ) -> Option<()> { diff --git a/fontique/src/backend/fontconfig/config.rs b/fontique/src/backend/fontconfig/config.rs index 41760482..d1653204 100644 --- a/fontique/src/backend/fontconfig/config.rs +++ b/fontique/src/backend/fontconfig/config.rs @@ -175,7 +175,7 @@ fn include_config(path: &Path, sink: &mut impl ParserSink) -> std::io::Result<() Ok(()) } -fn resolve_dir(node: Node, config_file_path: impl AsRef) -> Option { +fn resolve_dir(node: Node<'_, '_>, config_file_path: impl AsRef) -> Option { let dir_path = node.text()?; let (xdg_env, xdg_fallback) = match node.tag_name().name() { "include" => ("XDG_CONFIG_HOME", "~/.config"), diff --git a/fontique/src/font.rs b/fontique/src/font.rs index 92a6b9ba..f2eda60b 100644 --- a/fontique/src/font.rs +++ b/fontique/src/font.rs @@ -198,7 +198,11 @@ impl FontInfo { } impl FontInfo { - pub(crate) fn from_font_ref(font: &FontRef, source: SourceInfo, index: u32) -> Option { + pub(crate) fn from_font_ref( + font: &FontRef<'_>, + source: SourceInfo, + index: u32, + ) -> Option { let (stretch, style, weight) = read_attributes(font); let (axes, attr_axes) = if let Ok(fvar_axes) = font.fvar().and_then(|fvar| fvar.axes()) { let mut axes = SmallVec::<[AxisInfo; 1]>::with_capacity(fvar_axes.len()); @@ -336,7 +340,7 @@ impl Synthesis { } } -fn read_attributes(font: &FontRef) -> (FontStretch, FontStyle, FontWeight) { +fn read_attributes(font: &FontRef<'_>) -> (FontStretch, FontStyle, FontWeight) { use read_fonts::{ tables::{ head::{Head, MacStyle}, @@ -360,7 +364,7 @@ fn read_attributes(font: &FontRef) -> (FontStretch, FontStyle, FontWeight) { }) } - fn from_os2_post(os2: Os2, post: Option) -> (FontStretch, FontStyle, FontWeight) { + fn from_os2_post(os2: Os2<'_>, post: Option>) -> (FontStretch, FontStyle, FontWeight) { let stretch = stretch_from_width_class(os2.us_width_class()); // Bits 1 and 9 of the fsSelection field signify italic and // oblique, respectively. @@ -382,7 +386,7 @@ fn read_attributes(font: &FontRef) -> (FontStretch, FontStyle, FontWeight) { (stretch, style, weight) } - fn from_head(head: Head) -> (FontStretch, FontStyle, FontWeight) { + fn from_head(head: Head<'_>) -> (FontStretch, FontStyle, FontWeight) { let mac_style = head.mac_style(); let style = mac_style .contains(MacStyle::ITALIC) diff --git a/fontique/src/generic.rs b/fontique/src/generic.rs index 6dc7a6aa..728aa782 100644 --- a/fontique/src/generic.rs +++ b/fontique/src/generic.rs @@ -104,7 +104,7 @@ impl GenericFamily { } impl fmt::Display for GenericFamily { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let name = match self { Self::Serif => "serif", Self::SansSerif => "sans-serif", diff --git a/fontique/src/lib.rs b/fontique/src/lib.rs index 3dd64bff..4ab5f6bb 100644 --- a/fontique/src/lib.rs +++ b/fontique/src/lib.rs @@ -12,7 +12,6 @@ // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#![allow(elided_lifetimes_in_paths)] #![allow(missing_debug_implementations)] #![allow(missing_docs)] #![allow(single_use_lifetimes)] diff --git a/fontique/src/scan.rs b/fontique/src/scan.rs index 834bb795..080643ef 100644 --- a/fontique/src/scan.rs +++ b/fontique/src/scan.rs @@ -59,7 +59,7 @@ impl<'a> ScannedFont<'a> { pub fn scan_paths( paths: impl IntoIterator>, max_depth: u32, - mut f: impl FnMut(&ScannedFont), + mut f: impl FnMut(&ScannedFont<'_>), ) { for path in paths { scan_path_impl(path.as_ref(), max_depth, &mut f, 0); @@ -143,7 +143,7 @@ fn scan_collection( fn scan_path_impl( path: &Path, max_depth: u32, - f: &mut impl FnMut(&ScannedFont), + f: &mut impl FnMut(&ScannedFont<'_>), depth: u32, ) -> Option<()> { let metadata = path.metadata().ok()?; @@ -208,7 +208,7 @@ fn scan_font<'a>( } fn all_names( - name_table: &name::Name, + name_table: &name::Name<'_>, id: NameId, pool: &mut Vec, result: &mut Vec, diff --git a/parley/src/builder.rs b/parley/src/builder.rs index 6315508f..eda7ec59 100644 --- a/parley/src/builder.rs +++ b/parley/src/builder.rs @@ -69,7 +69,7 @@ pub struct TreeBuilder<'a, B: Brush> { } impl TreeBuilder<'_, B> { - pub fn push_style_span(&mut self, style: TextStyle) { + pub fn push_style_span(&mut self, style: TextStyle<'_, B>) { let resolved = self .lcx .rcx diff --git a/parley/src/context.rs b/parley/src/context.rs index 006da787..11d9753c 100644 --- a/parley/src/context.rs +++ b/parley/src/context.rs @@ -54,7 +54,7 @@ impl LayoutContext { &mut self, font_ctx: &mut FontContext, scale: f32, - raw_style: &TextStyle, + raw_style: &TextStyle<'_, B>, ) -> ResolvedStyle { self.rcx .resolve_entire_style_set(font_ctx, raw_style, scale) @@ -83,7 +83,7 @@ impl LayoutContext { &'a mut self, fcx: &'a mut FontContext, scale: f32, - raw_style: &TextStyle, + raw_style: &TextStyle<'_, B>, ) -> TreeBuilder<'a, B> { self.begin(); diff --git a/parley/src/layout/cursor.rs b/parley/src/layout/cursor.rs index 4b7f6a77..1dcb9a4c 100644 --- a/parley/src/layout/cursor.rs +++ b/parley/src/layout/cursor.rs @@ -82,7 +82,11 @@ impl Cursor { Some(Self::from_byte_index(layout, index, Affinity::Downstream)) } - fn from_cluster(layout: &Layout, cluster: Cluster, moving_right: bool) -> Self { + fn from_cluster( + layout: &Layout, + cluster: Cluster<'_, B>, + moving_right: bool, + ) -> Self { Self::from_byte_index( layout, cluster.text_range().start, @@ -896,7 +900,7 @@ enum AnchorBase { Line(Cursor, Cursor), } -fn cursor_rect(cluster: &Cluster, at_end: bool, size: f32) -> Rect { +fn cursor_rect(cluster: &Cluster<'_, B>, at_end: bool, size: f32) -> Rect { let line_x = (cluster.visual_offset().unwrap_or_default() + at_end.then(|| cluster.advance()).unwrap_or_default()) as f64; let line = cluster.line(); diff --git a/parley/src/layout/data.rs b/parley/src/layout/data.rs index 1814cd1d..fa7e25d2 100644 --- a/parley/src/layout/data.rs +++ b/parley/src/layout/data.rs @@ -279,7 +279,7 @@ impl LayoutData { font: Font, font_size: f32, synthesis: Synthesis, - shaper: Shaper, + shaper: Shaper<'_>, bidi_level: u8, word_spacing: f32, letter_spacing: f32, diff --git a/parley/src/layout/mod.rs b/parley/src/layout/mod.rs index a9b5e679..a4fb9a17 100644 --- a/parley/src/layout/mod.rs +++ b/parley/src/layout/mod.rs @@ -97,7 +97,7 @@ impl Layout { } /// Returns the line at the specified index. - pub fn get(&self, index: usize) -> Option> { + pub fn get(&self, index: usize) -> Option> { Some(Line { index: index as u32, layout: self, @@ -119,7 +119,7 @@ impl Layout { } /// Returns an iterator over the lines in the layout. - pub fn lines(&self) -> impl Iterator> + '_ + Clone { + pub fn lines(&self) -> impl Iterator> + '_ + Clone { self.data .lines .iter() @@ -132,7 +132,7 @@ impl Layout { } /// Returns line breaker to compute lines for the layout. - pub fn break_lines(&mut self) -> BreakLines { + pub fn break_lines(&mut self) -> BreakLines<'_, B> { BreakLines::new(self) } @@ -150,7 +150,7 @@ impl Layout { /// Returns the index and `Line` object for the line containing the /// given byte `index` in the source text. - pub(crate) fn line_for_byte_index(&self, index: usize) -> Option<(usize, Line)> { + pub(crate) fn line_for_byte_index(&self, index: usize) -> Option<(usize, Line<'_, B>)> { let line_index = self .data .lines @@ -173,7 +173,7 @@ impl Layout { /// The offset is specified in the direction orthogonal to line direction. /// For horizontal text, this is a vertical or y offset. If the offset is /// on a line boundary, it is considered to be contained by the later line. - pub(crate) fn line_for_offset(&self, offset: f32) -> Option<(usize, Line)> { + pub(crate) fn line_for_offset(&self, offset: f32) -> Option<(usize, Line<'_, B>)> { if offset < 0.0 { return Some((0, self.get(0)?)); } diff --git a/parley/src/lib.rs b/parley/src/lib.rs index 7ed9803a..c06266ce 100644 --- a/parley/src/lib.rs +++ b/parley/src/lib.rs @@ -81,7 +81,6 @@ // END LINEBENDER LINT SET #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#![allow(elided_lifetimes_in_paths)] #![allow(missing_debug_implementations)] #![allow(missing_docs)] #![allow(single_use_lifetimes)] diff --git a/parley/src/resolve/mod.rs b/parley/src/resolve/mod.rs index f1c5492f..b6e9e973 100644 --- a/parley/src/resolve/mod.rs +++ b/parley/src/resolve/mod.rs @@ -128,7 +128,7 @@ impl ResolveContext { pub(crate) fn resolve_property( &mut self, fcx: &mut FontContext, - property: &StyleProperty, + property: &StyleProperty<'_, B>, scale: f32, ) -> ResolvedProperty { use ResolvedProperty::*; @@ -161,7 +161,7 @@ impl ResolveContext { pub(crate) fn resolve_entire_style_set( &mut self, fcx: &mut FontContext, - raw_style: &TextStyle, + raw_style: &TextStyle<'_, B>, scale: f32, ) -> ResolvedStyle { ResolvedStyle { @@ -196,7 +196,7 @@ impl ResolveContext { pub(crate) fn resolve_stack( &mut self, fcx: &mut FontContext, - stack: &FontStack, + stack: &FontStack<'_>, ) -> Resolved { self.tmp_families.clear(); match stack { @@ -251,7 +251,7 @@ impl ResolveContext { /// Resolves font variation settings. pub(crate) fn resolve_variations( &mut self, - variations: &FontSettings, + variations: &FontSettings<'_, FontVariation>, ) -> Resolved { match variations { FontSettings::Source(source) => { @@ -276,7 +276,7 @@ impl ResolveContext { /// Resolves font feature settings. pub(crate) fn resolve_features( &mut self, - features: &FontSettings, + features: &FontSettings<'_, FontFeature>, ) -> Resolved { match features { FontSettings::Source(source) => { diff --git a/parley/src/resolve/tree.rs b/parley/src/resolve/tree.rs index 74569609..3292202e 100644 --- a/parley/src/resolve/tree.rs +++ b/parley/src/resolve/tree.rs @@ -69,7 +69,7 @@ impl TreeStyleBuilder { } pub(crate) fn push_uncommitted_text(&mut self, is_span_last: bool) { - let span_text: Cow = match self.white_space_collapse { + let span_text: Cow<'_, str> = match self.white_space_collapse { WhiteSpaceCollapse::Preserve => Cow::from(&self.uncommitted_text), WhiteSpaceCollapse::Collapse => { let mut span_text = self.uncommitted_text.as_str(); diff --git a/parley/src/shape.rs b/parley/src/shape.rs index d3ce8053..321e1534 100644 --- a/parley/src/shape.rs +++ b/parley/src/shape.rs @@ -361,7 +361,7 @@ impl PartialEq for SelectedFont { } impl partition::SelectedFont for SelectedFont { - fn font(&self) -> FontRef { + fn font(&self) -> FontRef<'_> { FontRef::from_index(self.font.blob.as_ref(), self.font.index as _).unwrap() } diff --git a/parley/src/style/font.rs b/parley/src/style/font.rs index 3c44f646..f0b3d48e 100644 --- a/parley/src/style/font.rs +++ b/parley/src/style/font.rs @@ -114,7 +114,7 @@ impl<'a> From<&'a [FontFamily<'a>]> for FontStack<'a> { } impl fmt::Display for FontFamily<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Named(name) => write!(f, "{:?}", name), Self::Generic(family) => write!(f, "{}", family), diff --git a/parley/src/tests/utils/renderer.rs b/parley/src/tests/utils/renderer.rs index 53321f7a..ba892775 100644 --- a/parley/src/tests/utils/renderer.rs +++ b/parley/src/tests/utils/renderer.rs @@ -26,7 +26,14 @@ pub(crate) struct RenderingConfig { pub selection_color: peniko::Color, } -fn draw_rect(pen: &mut TinySkiaPen, x: f32, y: f32, width: f32, height: f32, color: peniko::Color) { +fn draw_rect( + pen: &mut TinySkiaPen<'_>, + x: f32, + y: f32, + width: f32, + height: f32, + color: peniko::Color, +) { pen.set_origin(x, y); pen.set_color(to_tiny_skia(color)); pen.fill_rect(width, height); @@ -100,7 +107,11 @@ fn to_tiny_skia(color: PenikoColor) -> TinySkiaColor { TinySkiaColor::from_rgba8(color.r, color.g, color.b, color.a) } -fn render_glyph_run(glyph_run: &GlyphRun, pen: &mut TinySkiaPen<'_>, padding: u32) { +fn render_glyph_run( + glyph_run: &GlyphRun<'_, PenikoColor>, + pen: &mut TinySkiaPen<'_>, + padding: u32, +) { // Resolve properties of the GlyphRun let mut run_x = glyph_run.offset(); let run_y = glyph_run.baseline(); @@ -158,7 +169,7 @@ fn render_glyph_run(glyph_run: &GlyphRun, pen: &mut TinySkiaPen<'_> fn render_decoration( pen: &mut TinySkiaPen<'_>, - glyph_run: &GlyphRun, + glyph_run: &GlyphRun<'_, PenikoColor>, color: PenikoColor, offset: f32, width: f32, @@ -180,7 +191,7 @@ struct TinySkiaPen<'a> { } impl TinySkiaPen<'_> { - fn new(pixmap: PixmapMut) -> TinySkiaPen { + fn new(pixmap: PixmapMut<'_>) -> TinySkiaPen<'_> { TinySkiaPen { pixmap, x: 0.0,