Use clippy workspace lints and inline format args (#2771)
This commit is contained in:
parent
3c2b61ee7d
commit
e36a18b991
@ -132,3 +132,6 @@ codegen-units = 1
|
||||
|
||||
[profile.release.package."typst-cli"]
|
||||
strip = true
|
||||
|
||||
[workspace.lints.clippy]
|
||||
uninlined_format_args = "warn"
|
||||
|
@ -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
|
||||
|
@ -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}")
|
||||
}
|
||||
}
|
||||
|
@ -102,12 +102,10 @@ impl Release {
|
||||
pub fn from_tag(tag: Option<&Version>) -> StrResult<Release> {
|
||||
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",
|
||||
),
|
||||
};
|
||||
|
||||
|
@ -25,3 +25,6 @@ typed-arena = { workspace = true }
|
||||
unicode_names2 = { workspace = true }
|
||||
unscanny = { workspace = true }
|
||||
yaml-front-matter = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -24,3 +24,6 @@ if_chain = { workspace = true }
|
||||
log = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
unscanny = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -22,3 +22,6 @@ heck = { workspace = true }
|
||||
proc-macro2 = { workspace = true }
|
||||
quote = { workspace = true }
|
||||
syn = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -248,10 +248,10 @@ fn parse_field(field: &syn::Field) -> Result<Field> {
|
||||
default: parse_attr::<syn::Expr>(&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,
|
||||
|
@ -32,3 +32,6 @@ ttf-parser = { workspace = true }
|
||||
unicode-properties = { workspace = true }
|
||||
unscanny = { workspace = true }
|
||||
xmp-writer = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -27,3 +27,6 @@ roxmltree = { workspace = true }
|
||||
tiny-skia = { workspace = true }
|
||||
ttf-parser = { workspace = true }
|
||||
usvg = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -25,3 +25,6 @@ tracing = { workspace = true }
|
||||
ttf-parser = { workspace = true }
|
||||
xmlparser = { workspace = true }
|
||||
xmlwriter = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -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)),
|
||||
|
@ -26,3 +26,6 @@ unicode-math-class = { workspace = true }
|
||||
unicode-script = { workspace = true }
|
||||
unicode-segmentation = { workspace = true }
|
||||
unscanny = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -65,3 +65,6 @@ wasmi = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
stacker = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -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")
|
||||
|
@ -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())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user