Skip to content

Commit

Permalink
Fix elided_lifetimes_in_paths lints (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Dec 9, 2024
1 parent f9bb8fb commit 7848712
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 45 deletions.
3 changes: 1 addition & 2 deletions examples/vello_editor/src/main.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -364,7 +363,7 @@ fn create_winit_window(event_loop: &ActiveEventLoop) -> Arc<Window> {
}

/// 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 {
Expand Down
6 changes: 3 additions & 3 deletions fontique/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 10 additions & 5 deletions fontique/src/backend/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,20 @@ impl SystemFonts {
.attribute("lang")
.map(|s| s.split(',').collect::<Vec<&str>>())
{
let (_has_for, hasnt_for): (Vec<Node>, Vec<Node>) = child
let (_has_for, hasnt_for): (
Vec<Node<'_, '_>>,
Vec<Node<'_, '_>>,
) = child
.children()
.partition(|c| c.attribute("fallbackFor").is_some());
{
// general fallback families
let (ps_named, _ps_unnamed): (Vec<Node>, Vec<Node>) =
hasnt_for.iter().partition(|c| {
c.attribute("postScriptName").is_some()
});
let (ps_named, _ps_unnamed): (
Vec<Node<'_, '_>>,
Vec<Node<'_, '_>>,
) = hasnt_for
.iter()
.partition(|c| c.attribute("postScriptName").is_some());

if let Some(family) = ps_named.iter().find_map(|x| {
postscript_names
Expand Down
2 changes: 1 addition & 1 deletion fontique/src/backend/fontconfig/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
font: &mut CachedFont,
) -> Option<()> {
Expand Down
2 changes: 1 addition & 1 deletion fontique/src/backend/fontconfig/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path>) -> Option<PathBuf> {
fn resolve_dir(node: Node<'_, '_>, config_file_path: impl AsRef<Path>) -> Option<PathBuf> {
let dir_path = node.text()?;
let (xdg_env, xdg_fallback) = match node.tag_name().name() {
"include" => ("XDG_CONFIG_HOME", "~/.config"),
Expand Down
12 changes: 8 additions & 4 deletions fontique/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ impl FontInfo {
}

impl FontInfo {
pub(crate) fn from_font_ref(font: &FontRef, source: SourceInfo, index: u32) -> Option<Self> {
pub(crate) fn from_font_ref(
font: &FontRef<'_>,
source: SourceInfo,
index: u32,
) -> Option<Self> {
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());
Expand Down Expand Up @@ -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},
Expand All @@ -360,7 +364,7 @@ fn read_attributes(font: &FontRef) -> (FontStretch, FontStyle, FontWeight) {
})
}

fn from_os2_post(os2: Os2, post: Option<Post>) -> (FontStretch, FontStyle, FontWeight) {
fn from_os2_post(os2: Os2<'_>, post: Option<Post<'_>>) -> (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.
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fontique/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion fontique/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions fontique/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> ScannedFont<'a> {
pub fn scan_paths(
paths: impl IntoIterator<Item = impl AsRef<Path>>,
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);
Expand Down Expand Up @@ -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()?;
Expand Down Expand Up @@ -208,7 +208,7 @@ fn scan_font<'a>(
}

fn all_names(
name_table: &name::Name,
name_table: &name::Name<'_>,
id: NameId,
pool: &mut Vec<String>,
result: &mut Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion parley/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct TreeBuilder<'a, B: Brush> {
}

impl<B: Brush> TreeBuilder<'_, B> {
pub fn push_style_span(&mut self, style: TextStyle<B>) {
pub fn push_style_span(&mut self, style: TextStyle<'_, B>) {
let resolved = self
.lcx
.rcx
Expand Down
4 changes: 2 additions & 2 deletions parley/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<B: Brush> LayoutContext<B> {
&mut self,
font_ctx: &mut FontContext,
scale: f32,
raw_style: &TextStyle<B>,
raw_style: &TextStyle<'_, B>,
) -> ResolvedStyle<B> {
self.rcx
.resolve_entire_style_set(font_ctx, raw_style, scale)
Expand Down Expand Up @@ -83,7 +83,7 @@ impl<B: Brush> LayoutContext<B> {
&'a mut self,
fcx: &'a mut FontContext,
scale: f32,
raw_style: &TextStyle<B>,
raw_style: &TextStyle<'_, B>,
) -> TreeBuilder<'a, B> {
self.begin();

Expand Down
8 changes: 6 additions & 2 deletions parley/src/layout/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ impl Cursor {
Some(Self::from_byte_index(layout, index, Affinity::Downstream))
}

fn from_cluster<B: Brush>(layout: &Layout<B>, cluster: Cluster<B>, moving_right: bool) -> Self {
fn from_cluster<B: Brush>(
layout: &Layout<B>,
cluster: Cluster<'_, B>,
moving_right: bool,
) -> Self {
Self::from_byte_index(
layout,
cluster.text_range().start,
Expand Down Expand Up @@ -896,7 +900,7 @@ enum AnchorBase {
Line(Cursor, Cursor),
}

fn cursor_rect<B: Brush>(cluster: &Cluster<B>, at_end: bool, size: f32) -> Rect {
fn cursor_rect<B: Brush>(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();
Expand Down
2 changes: 1 addition & 1 deletion parley/src/layout/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl<B: Brush> LayoutData<B> {
font: Font,
font_size: f32,
synthesis: Synthesis,
shaper: Shaper,
shaper: Shaper<'_>,
bidi_level: u8,
word_spacing: f32,
letter_spacing: f32,
Expand Down
10 changes: 5 additions & 5 deletions parley/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<B: Brush> Layout<B> {
}

/// Returns the line at the specified index.
pub fn get(&self, index: usize) -> Option<Line<B>> {
pub fn get(&self, index: usize) -> Option<Line<'_, B>> {
Some(Line {
index: index as u32,
layout: self,
Expand All @@ -119,7 +119,7 @@ impl<B: Brush> Layout<B> {
}

/// Returns an iterator over the lines in the layout.
pub fn lines(&self) -> impl Iterator<Item = Line<B>> + '_ + Clone {
pub fn lines(&self) -> impl Iterator<Item = Line<'_, B>> + '_ + Clone {
self.data
.lines
.iter()
Expand All @@ -132,7 +132,7 @@ impl<B: Brush> Layout<B> {
}

/// Returns line breaker to compute lines for the layout.
pub fn break_lines(&mut self) -> BreakLines<B> {
pub fn break_lines(&mut self) -> BreakLines<'_, B> {
BreakLines::new(self)
}

Expand All @@ -150,7 +150,7 @@ impl<B: Brush> Layout<B> {

/// 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<B>)> {
pub(crate) fn line_for_byte_index(&self, index: usize) -> Option<(usize, Line<'_, B>)> {
let line_index = self
.data
.lines
Expand All @@ -173,7 +173,7 @@ impl<B: Brush> Layout<B> {
/// 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<B>)> {
pub(crate) fn line_for_offset(&self, offset: f32) -> Option<(usize, Line<'_, B>)> {
if offset < 0.0 {
return Some((0, self.get(0)?));
}
Expand Down
1 change: 0 additions & 1 deletion parley/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
10 changes: 5 additions & 5 deletions parley/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl ResolveContext {
pub(crate) fn resolve_property<B: Brush>(
&mut self,
fcx: &mut FontContext,
property: &StyleProperty<B>,
property: &StyleProperty<'_, B>,
scale: f32,
) -> ResolvedProperty<B> {
use ResolvedProperty::*;
Expand Down Expand Up @@ -161,7 +161,7 @@ impl ResolveContext {
pub(crate) fn resolve_entire_style_set<B: Brush>(
&mut self,
fcx: &mut FontContext,
raw_style: &TextStyle<B>,
raw_style: &TextStyle<'_, B>,
scale: f32,
) -> ResolvedStyle<B> {
ResolvedStyle {
Expand Down Expand Up @@ -196,7 +196,7 @@ impl ResolveContext {
pub(crate) fn resolve_stack(
&mut self,
fcx: &mut FontContext,
stack: &FontStack,
stack: &FontStack<'_>,
) -> Resolved<FamilyId> {
self.tmp_families.clear();
match stack {
Expand Down Expand Up @@ -251,7 +251,7 @@ impl ResolveContext {
/// Resolves font variation settings.
pub(crate) fn resolve_variations(
&mut self,
variations: &FontSettings<FontVariation>,
variations: &FontSettings<'_, FontVariation>,
) -> Resolved<FontVariation> {
match variations {
FontSettings::Source(source) => {
Expand All @@ -276,7 +276,7 @@ impl ResolveContext {
/// Resolves font feature settings.
pub(crate) fn resolve_features(
&mut self,
features: &FontSettings<FontFeature>,
features: &FontSettings<'_, FontFeature>,
) -> Resolved<FontFeature> {
match features {
FontSettings::Source(source) => {
Expand Down
2 changes: 1 addition & 1 deletion parley/src/resolve/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<B: Brush> TreeStyleBuilder<B> {
}

pub(crate) fn push_uncommitted_text(&mut self, is_span_last: bool) {
let span_text: Cow<str> = 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();
Expand Down
2 changes: 1 addition & 1 deletion parley/src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion parley/src/style/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading

0 comments on commit 7848712

Please sign in to comment.