diff --git a/Cargo.toml b/Cargo.toml index f2d280f3b..357dc7eff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,3 +132,6 @@ codegen-units = 1 [profile.release.package."typst-cli"] strip = true + +[workspace.lints.clippy] +uninlined_format_args = "warn" diff --git a/crates/typst-cli/Cargo.toml b/crates/typst-cli/Cargo.toml index 3819469e4..1854e8563 100644 --- a/crates/typst-cli/Cargo.toml +++ b/crates/typst-cli/Cargo.toml @@ -74,3 +74,6 @@ embed-fonts = [] # Permits the CLI to update itself without a package manager self-update = ["dep:self-replace", "dep:xz2", "dep:zip", "ureq/json"] + +[lints] +workspace = true diff --git a/crates/typst-cli/src/download.rs b/crates/typst-cli/src/download.rs index e5a97cda4..0fff7b85e 100644 --- a/crates/typst-cli/src/download.rs +++ b/crates/typst-cli/src/download.rs @@ -198,7 +198,7 @@ impl RemoteReader { })) ) } - None => format!("Total: {} Speed: {} Elapsed: {}", total, speed_h, elapsed,), + None => format!("Total: {total} Speed: {speed_h} Elapsed: {elapsed}"), }; let _ = write!(self.stderr, "{output}"); @@ -252,6 +252,6 @@ fn as_time_unit(size: usize, include_suffix: bool) -> String { } else if size >= KI { format!("{:5.1} KiB{}", size / KI, suffix) } else { - format!("{size:3.0} B{}", suffix) + format!("{size:3.0} B{suffix}") } } diff --git a/crates/typst-cli/src/update.rs b/crates/typst-cli/src/update.rs index cde77dbbe..cfb93454b 100644 --- a/crates/typst-cli/src/update.rs +++ b/crates/typst-cli/src/update.rs @@ -102,12 +102,10 @@ impl Release { pub fn from_tag(tag: Option<&Version>) -> StrResult { let url = match tag { Some(tag) => format!( - "https://api.github.com/repos/{}/{}/releases/tags/v{}", - TYPST_GITHUB_ORG, TYPST_REPO, tag + "https://api.github.com/repos/{TYPST_GITHUB_ORG}/{TYPST_REPO}/releases/tags/v{tag}" ), None => format!( - "https://api.github.com/repos/{}/{}/releases/latest", - TYPST_GITHUB_ORG, TYPST_REPO + "https://api.github.com/repos/{TYPST_GITHUB_ORG}/{TYPST_REPO}/releases/latest", ), }; diff --git a/crates/typst-docs/Cargo.toml b/crates/typst-docs/Cargo.toml index 152f5e790..a5bc3fdb0 100644 --- a/crates/typst-docs/Cargo.toml +++ b/crates/typst-docs/Cargo.toml @@ -25,3 +25,6 @@ typed-arena = { workspace = true } unicode_names2 = { workspace = true } unscanny = { workspace = true } yaml-front-matter = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst-ide/Cargo.toml b/crates/typst-ide/Cargo.toml index f7b072969..45e64f213 100644 --- a/crates/typst-ide/Cargo.toml +++ b/crates/typst-ide/Cargo.toml @@ -24,3 +24,6 @@ if_chain = { workspace = true } log = { workspace = true } serde = { workspace = true } unscanny = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst-macros/Cargo.toml b/crates/typst-macros/Cargo.toml index 2bb3ba1c0..8c58260ab 100644 --- a/crates/typst-macros/Cargo.toml +++ b/crates/typst-macros/Cargo.toml @@ -22,3 +22,6 @@ heck = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } syn = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst-macros/src/elem.rs b/crates/typst-macros/src/elem.rs index ce80cc667..acb73ba54 100644 --- a/crates/typst-macros/src/elem.rs +++ b/crates/typst-macros/src/elem.rs @@ -248,10 +248,10 @@ fn parse_field(field: &syn::Field) -> Result { default: parse_attr::(&mut attrs, "default")?.flatten(), vis: field.vis.clone(), ident: ident.clone(), - ident_in: Ident::new(&format!("{}_in", ident), ident.span()), - with_ident: Ident::new(&format!("with_{}", ident), ident.span()), - push_ident: Ident::new(&format!("push_{}", ident), ident.span()), - set_ident: Ident::new(&format!("set_{}", ident), ident.span()), + ident_in: Ident::new(&format!("{ident}_in"), ident.span()), + with_ident: Ident::new(&format!("with_{ident}"), ident.span()), + push_ident: Ident::new(&format!("push_{ident}"), ident.span()), + set_ident: Ident::new(&format!("set_{ident}"), ident.span()), enum_ident: Ident::new(&ident.to_string().to_upper_camel_case(), ident.span()), const_ident: Ident::new(&ident.to_string().to_shouty_snake_case(), ident.span()), ty: field.ty.clone(), @@ -530,7 +530,7 @@ fn create_with_field_method(field: &Field) -> TokenStream { default, .. } = field; - let doc = format!("Set the [`{}`](Self::{}) field.", name, ident); + let doc = format!("Set the [`{name}`](Self::{ident}) field."); let set = if field.inherent() || (*synthesized && default.is_some()) { quote! { self.#ident = #ident; } @@ -558,7 +558,7 @@ fn create_push_field_method(field: &Field) -> TokenStream { default, .. } = field; - let doc = format!("Push the [`{}`](Self::{}) field.", name, ident); + let doc = format!("Push the [`{name}`](Self::{ident}) field."); let set = if (field.inherent() && !synthesized) || (*synthesized && default.is_some()) { quote! { self.#ident = #ident; } @@ -577,7 +577,7 @@ fn create_push_field_method(field: &Field) -> TokenStream { fn create_set_field_method(element: &Elem, field: &Field) -> TokenStream { let elem = &element.ident; let Field { vis, ident, set_ident, enum_ident, ty, name, .. } = field; - let doc = format!("Create a style property for the `{}` field.", name); + let doc = format!("Create a style property for the `{name}` field."); quote! { #[doc = #doc] #vis fn #set_ident(#ident: #ty) -> #foundations::Style { @@ -593,7 +593,7 @@ fn create_set_field_method(element: &Elem, field: &Field) -> TokenStream { /// Create a style chain access method for a field. fn create_field_in_method(element: &Elem, field: &Field) -> TokenStream { let Field { vis, ident_in, name, output, .. } = field; - let doc = format!("Access the `{}` field in the given style chain.", name); + let doc = format!("Access the `{name}` field in the given style chain."); let access = create_style_chain_access(element, field, quote! { None }); let output = if field.borrowed { @@ -903,8 +903,8 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream { ) .unwrap_or_else(|| quote! { None }); - let unknown_field = format!("unknown field {{}} on {}", name); - let label_error = format!("cannot set label on {}", name); + let unknown_field = format!("unknown field {{}} on {name}"); + let label_error = format!("cannot set label on {name}"); let data = quote! { #foundations::NativeElementData { name: #name, diff --git a/crates/typst-pdf/Cargo.toml b/crates/typst-pdf/Cargo.toml index 74e38a697..f2f05f65e 100644 --- a/crates/typst-pdf/Cargo.toml +++ b/crates/typst-pdf/Cargo.toml @@ -32,3 +32,6 @@ ttf-parser = { workspace = true } unicode-properties = { workspace = true } unscanny = { workspace = true } xmp-writer = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst-render/Cargo.toml b/crates/typst-render/Cargo.toml index 0c552cd3c..c1aa571ff 100644 --- a/crates/typst-render/Cargo.toml +++ b/crates/typst-render/Cargo.toml @@ -27,3 +27,6 @@ roxmltree = { workspace = true } tiny-skia = { workspace = true } ttf-parser = { workspace = true } usvg = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst-svg/Cargo.toml b/crates/typst-svg/Cargo.toml index 628c34f8d..7ab91c1be 100644 --- a/crates/typst-svg/Cargo.toml +++ b/crates/typst-svg/Cargo.toml @@ -25,3 +25,6 @@ tracing = { workspace = true } ttf-parser = { workspace = true } xmlparser = { workspace = true } xmlwriter = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst-svg/src/lib.rs b/crates/typst-svg/src/lib.rs index 205cff148..29e423106 100644 --- a/crates/typst-svg/src/lib.rs +++ b/crates/typst-svg/src/lib.rs @@ -446,7 +446,7 @@ impl SVGRenderer { self.xml.start_element("use"); self.xml.write_attribute_fmt("xlink:href", format_args!("#{id}")); - self.xml.write_attribute_fmt("x", format_args!("{}", x_offset)); + self.xml.write_attribute_fmt("x", format_args!("{x_offset}")); self.write_fill( &text.fill, Size::new(Abs::pt(width), Abs::pt(height)), diff --git a/crates/typst-syntax/Cargo.toml b/crates/typst-syntax/Cargo.toml index 681189bd3..362b58989 100644 --- a/crates/typst-syntax/Cargo.toml +++ b/crates/typst-syntax/Cargo.toml @@ -26,3 +26,6 @@ unicode-math-class = { workspace = true } unicode-script = { workspace = true } unicode-segmentation = { workspace = true } unscanny = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst/Cargo.toml b/crates/typst/Cargo.toml index c9c19f8e8..b206d8bb3 100644 --- a/crates/typst/Cargo.toml +++ b/crates/typst/Cargo.toml @@ -65,3 +65,6 @@ wasmi = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] stacker = { workspace = true } + +[lints] +workspace = true diff --git a/crates/typst/src/diag.rs b/crates/typst/src/diag.rs index 41339dff5..a8142f3f9 100644 --- a/crates/typst/src/diag.rs +++ b/crates/typst/src/diag.rs @@ -216,7 +216,7 @@ impl Display for Tracepoint { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Tracepoint::Call(Some(name)) => { - write!(f, "error occurred in this call of function `{}`", name) + write!(f, "error occurred in this call of function `{name}`") } Tracepoint::Call(None) => { write!(f, "error occurred in this function call") diff --git a/crates/typst/src/foundations/array.rs b/crates/typst/src/foundations/array.rs index 8f2e9149e..86d4c2ac8 100644 --- a/crates/typst/src/foundations/array.rs +++ b/crates/typst/src/foundations/array.rs @@ -139,7 +139,7 @@ impl Array { let count = self .len() .checked_mul(n) - .ok_or_else(|| format!("cannot repeat this array {} times", n))?; + .ok_or_else(|| format!("cannot repeat this array {n} times"))?; Ok(self.iter().cloned().cycle().take(count).collect()) }