Skip to content

Commit

Permalink
[clippy] Fixup for 1.72.0
Browse files Browse the repository at this point in the history
One funny one here; clippy didn't like our Clone impls in some generated
code, so I had to fixup the codegen tool to emit something clippy *did*
like. This ended up being no problem though.
  • Loading branch information
cmyr authored and dfrg committed Aug 25, 2023
1 parent c8a9a8c commit 94baa49
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion font-codegen/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) fn format(tables: proc_macro2::TokenStream) -> Result<String, syn::Er
// convert doc comment attributes into normal doc comments
let doc_comments = regex::Regex::new(r##"#\[doc = r?#?"(.*)"#?\]"##).unwrap();
let source_str = doc_comments.replace_all(&source_str, "///$1");
let newlines_before_docs = regex::Regex::new(r#"([;\}])\r?\n( *)(///|pub|impl|#)"#).unwrap();
let newlines_before_docs = regex::Regex::new(r"([;\}])\r?\n( *)(///|pub|impl|#)").unwrap();
let source_str = newlines_before_docs.replace_all(&source_str, "$1\n\n$2$3");

// add newlines after top-level items
Expand Down
2 changes: 1 addition & 1 deletion font-codegen/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ impl Parse for InlineExpr {
let span = tokens.span();
let s = tokens.to_string();
let mut idents = Vec::new();
let find_dollar_idents = regex::Regex::new(r#"(\$) (\w+)"#).unwrap();
let find_dollar_idents = regex::Regex::new(r"(\$) (\w+)").unwrap();
for ident in find_dollar_idents.captures_iter(&s) {
let text = ident.get(2).unwrap().as_str();
let ident = syn::parse_str::<syn::Ident>(text).map_err(|_| {
Expand Down
12 changes: 2 additions & 10 deletions font-codegen/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@ pub(crate) fn generate(item: &Table) -> syn::Result<TokenStream> {
let shape_fields = item.iter_shape_fields();
let derive_clone_copy = generic.is_none().then(|| quote!(Clone, Copy));
let impl_clone_copy = generic.is_some().then(|| {
let clone_fields = item
.iter_shape_field_names()
.map(|name| quote!(#name: self.#name));
quote! {
impl<#generic> Clone for #marker_name<#generic> {
fn clone(&self) -> Self {
Self {
#( #clone_fields, )*
offset_type: std::marker::PhantomData,
}
*self
}
}

Expand Down Expand Up @@ -327,9 +321,7 @@ fn generate_to_owned_impl(item: &Table, parse_module: &syn::Path) -> syn::Result
let parse_generic = comp_generic
.is_some()
.then(|| syn::Ident::new("U", Span::call_site()));
let impl_generics = comp_generic
.into_iter()
.chain(parse_generic.as_ref().into_iter());
let impl_generics = comp_generic.into_iter().chain(parse_generic.as_ref());
let impl_generics2 = impl_generics.clone();
let where_clause = comp_generic.map(|t| {
quote! {
Expand Down
4 changes: 1 addition & 3 deletions read-fonts/generated/generated_gpos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3445,9 +3445,7 @@ impl<T> ExtensionPosFormat1Marker<T> {

impl<T> Clone for ExtensionPosFormat1Marker<T> {
fn clone(&self) -> Self {
Self {
offset_type: std::marker::PhantomData,
}
*self
}
}

Expand Down
4 changes: 1 addition & 3 deletions read-fonts/generated/generated_gsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,7 @@ impl<T> ExtensionSubstFormat1Marker<T> {

impl<T> Clone for ExtensionSubstFormat1Marker<T> {
fn clone(&self) -> Self {
Self {
offset_type: std::marker::PhantomData,
}
*self
}
}

Expand Down
10 changes: 2 additions & 8 deletions read-fonts/generated/generated_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,7 @@ impl<T> LookupListMarker<T> {

impl<T> Clone for LookupListMarker<T> {
fn clone(&self) -> Self {
Self {
lookup_offsets_byte_len: self.lookup_offsets_byte_len,
offset_type: std::marker::PhantomData,
}
*self
}
}

Expand Down Expand Up @@ -786,10 +783,7 @@ impl<T> LookupMarker<T> {

impl<T> Clone for LookupMarker<T> {
fn clone(&self) -> Self {
Self {
subtable_offsets_byte_len: self.subtable_offsets_byte_len,
offset_type: std::marker::PhantomData,
}
*self
}
}

Expand Down
2 changes: 1 addition & 1 deletion read-fonts/src/tables/postscript/fd_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod tests {
fds[gid as usize] = *font_index;
}
}
buf = buf.extend(fds.into_iter());
buf = buf.extend(fds);
buf
};
let format3 = {
Expand Down
2 changes: 1 addition & 1 deletion write-fonts/src/graph/splitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ mod tests {
const N_GLYPHS: u16 = 1500; // manually determined to cause overflow

let mut pairs = Vec::new();
for (advance, g1) in [0u16..N_GLYPHS].into_iter().flatten().enumerate() {
for (advance, g1) in (0u16..N_GLYPHS).enumerate() {
pairs.push(KernPair(GlyphId::new(g1), GlyphId::new(5), advance as _));
pairs.push(KernPair(GlyphId::new(g1), GlyphId::new(6), advance as _));
pairs.push(KernPair(GlyphId::new(g1), GlyphId::new(7), advance as _));
Expand Down

0 comments on commit 94baa49

Please sign in to comment.