From d260961426b01f7643ba0f35f493bdb671eeaf3f Mon Sep 17 00:00:00 2001 From: Winston H <56998716+winstxnhdw@users.noreply.github.com> Date: Wed, 26 Jun 2024 07:05:10 +0800 Subject: [PATCH 01/13] fix: use c++ 17 --- crates/xetex_layout/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/xetex_layout/build.rs b/crates/xetex_layout/build.rs index bdd0d03fc..558fd29e1 100644 --- a/crates/xetex_layout/build.rs +++ b/crates/xetex_layout/build.rs @@ -86,7 +86,7 @@ fn main() { let mut cppcfg = cc::Build::new(); let cppflags = [ - "-std=c++14", + "-std=c++17", "-Wall", "-Wdate-time", "-Wendif-labels", From 6b49ca8db40aaca29cb375ce75add3e575558375 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 02:39:22 +0800 Subject: [PATCH 02/13] build/fix: update `time` --- Cargo.lock | 9 +++++---- Cargo.toml | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 882dcd43b..91a03d4f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2633,6 +2633,7 @@ dependencies = [ "tectonic_xetex_layout", "tempfile", "termcolor", + "time", "tokio", "toml", "url", @@ -2934,9 +2935,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -2957,9 +2958,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", diff --git a/Cargo.toml b/Cargo.toml index 97244eb96..c4a359453 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,6 +97,7 @@ watchexec-filterer-globset = "3.0" watchexec-signals = "2.0" watchexec-supervisor = "1.0" zip = { version = "^0.6", default-features = false, features = ["deflate"] } +time = "0.3.36" [features] default = ["geturl-reqwest", "serialization"] From 88b4eb6b3f7d83d2a45be131c80c4d83db754dec Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 04:10:39 +0800 Subject: [PATCH 03/13] fix(clippy): implement idiomatic `Display` instead --- crates/io_base/src/digest.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/io_base/src/digest.rs b/crates/io_base/src/digest.rs index 1a0dbe995..0cfb5fbd2 100644 --- a/crates/io_base/src/digest.rs +++ b/crates/io_base/src/digest.rs @@ -4,7 +4,7 @@ //! Helpers to tidy up the computation of digests in various places. use std::{ - fs, + fmt, fs, path::{Path, PathBuf}, str::FromStr, }; @@ -103,9 +103,9 @@ impl DigestData { } } -impl ToString for DigestData { - fn to_string(&self) -> String { - bytes_to_hex(&self.0) +impl fmt::Display for DigestData { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", bytes_to_hex(&self.0)) } } From cdb3d7e1b61c285f690ec097a8a01e53d1aa1d65 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 04:54:50 +0800 Subject: [PATCH 04/13] fix(clippy): simplify `contains` --- crates/bundles/src/cache.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/bundles/src/cache.rs b/crates/bundles/src/cache.rs index 5d43813fb..4c8cfa98a 100644 --- a/crates/bundles/src/cache.rs +++ b/crates/bundles/src/cache.rs @@ -460,7 +460,7 @@ impl CachingBundle { // If a filename contains newline characters, it will mess up our // line-based manifest format. Be paranoid and refuse to record such // filenames. - if !name.contains(|c| c == '\n' || c == '\r') { + if !name.contains(['\n', '\r']) { writeln!(man, "{name} {length} {digest_text}")?; } @@ -515,9 +515,7 @@ impl CachingBundle { // giving incorrect results if we pulled files out of the cache // before this invocation. Rewrite the digest file so that next time // we'll start afresh, then bail. - file_create_write(&self.digest_path, |f| { - writeln!(f, "{}", pull_data.digest.to_string()) - })?; + file_create_write(&self.digest_path, |f| writeln!(f, "{}", pull_data.digest))?; bail!("backend digest changed; rerun tectonic to use updated information"); } From 1c582841c69b299970edea5ffd60d2592d5459b0 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 04:55:07 +0800 Subject: [PATCH 05/13] fix(clippy): avoid unnecessary borrow --- crates/engine_spx2html/src/assets.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine_spx2html/src/assets.rs b/crates/engine_spx2html/src/assets.rs index edd08ed6e..21f73a743 100644 --- a/crates/engine_spx2html/src/assets.rs +++ b/crates/engine_spx2html/src/assets.rs @@ -179,7 +179,7 @@ pub(crate) fn create_output_path( for piece in dest_path.split('/') { if let Some(out_path) = out_path.as_mut() { - match std::fs::create_dir(&out_path) { + match std::fs::create_dir(out_path.as_path()) { Ok(_) => {} Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {} Err(e) => { From 3eb7fba0b7f2c665519b284b64243abfc3abdd74 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 04:55:29 +0800 Subject: [PATCH 06/13] fix(clippy): silence intended unknown profile --- crates/engine_xetex/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/engine_xetex/build.rs b/crates/engine_xetex/build.rs index 992b3511c..a34282b4d 100644 --- a/crates/engine_xetex/build.rs +++ b/crates/engine_xetex/build.rs @@ -25,6 +25,7 @@ fn main() { let profile_target_requires_frame_pointer: bool = target_cfg!(not(all(target_os = "linux", target_arch = "x86_64"))); + #[allow(unexpected_cfgs)] const PROFILE_BUILD_ENABLED: bool = cfg!(feature = "profile"); let profile_config = |cfg: &mut cc::Build| { From cf48f48ae9a118fbc2c4f26e4ade48a8a3e55cf0 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 05:02:56 +0800 Subject: [PATCH 07/13] fix(clippy): annotate `transmute` --- crates/xdv/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/xdv/src/lib.rs b/crates/xdv/src/lib.rs index c3923cf4a..d15d7e09a 100644 --- a/crates/xdv/src/lib.rs +++ b/crates/xdv/src/lib.rs @@ -1229,7 +1229,7 @@ impl<'a, T: XdvEvents> Cursor<'a, T> { return Err(InternalError::NeedMoreData); } - let rv = unsafe { mem::transmute(self.buf[0]) }; + let rv = unsafe { mem::transmute::(self.buf[0]) }; self.buf = &self.buf[1..]; self.offset += 1; Ok(rv) From 63ce5e54b07c38d8ef2d447ac1508aedd3b34c14 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 05:03:23 +0800 Subject: [PATCH 08/13] fix(clippy): remove unnecessary `to_string()` --- src/io/format_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/format_cache.rs b/src/io/format_cache.rs index dbb4e182f..2b02fe1f6 100644 --- a/src/io/format_cache.rs +++ b/src/io/format_cache.rs @@ -55,7 +55,7 @@ impl FormatCache { let mut p = self.formats_base.clone(); p.push(format!( "{}-{}-{}.fmt", - self.bundle_digest.to_string(), + self.bundle_digest, stem, crate::FORMAT_SERIAL )); From 3f1de80260121ea98f0bfaefd3bafa5edc5db4f4 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 05:06:35 +0800 Subject: [PATCH 09/13] fix(clippy): clone `out_path` --- crates/engine_spx2html/src/fontfile.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/engine_spx2html/src/fontfile.rs b/crates/engine_spx2html/src/fontfile.rs index 8455f06b4..65289b101 100644 --- a/crates/engine_spx2html/src/fontfile.rs +++ b/crates/engine_spx2html/src/fontfile.rs @@ -426,9 +426,10 @@ impl FontFileData { if let Some(out_path) = out_path.as_mut() { out_path.push(rel_path); + let display_path = out_path.clone(); atry!( - std::fs::write(&out_path, &self.buffer); - ["cannot write output file `{}`", out_path.display()] + std::fs::write(out_path, &self.buffer); + ["cannot write output file `{}`", display_path.display()] ); } @@ -490,9 +491,10 @@ impl FontFileData { out_path.pop(); out_path.push(&varname); + let display_path = out_path.clone(); atry!( - std::fs::write(&out_path, &buffer); - ["cannot write output file `{}`", out_path.display()] + std::fs::write(out_path, &buffer); + ["cannot write output file `{}`", display_path.display()] ); } From 0f3660747c6aa1b9d2283179ab39fc47a836ed79 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 05:07:40 +0800 Subject: [PATCH 10/13] fix(clippy): ignore `cfg(backtrace)` --- Cargo.toml | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c4a359453..f63747a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,17 +16,14 @@ documentation = "https://docs.rs/tectonic" repository = "/~https://github.com/tectonic-typesetting/tectonic/" readme = "CARGO_README.md" keywords = ["tex", "latex", "typesetting", "font"] -categories = [ - "command-line-interface", - "parser-implementations", - "rendering", - "science", - "text-processing", -] +categories = ["command-line-interface", "parser-implementations", "rendering", "science", "text-processing"] license = "MIT" edition = "2018" exclude = ["/dist/", "/reference_sources/"] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(backtrace)'] } + [badges] travis-ci = { repository = "tectonic-typesetting/tectonic" } codecov = { repository = "tectonic-typesetting/tectonic", service = "github" } @@ -115,10 +112,7 @@ external-harfbuzz = ["tectonic_engine_xetex/external-harfbuzz"] geturl-curl = ["tectonic_bundles/geturl-curl", "tectonic_geturl/curl"] geturl-reqwest = ["tectonic_bundles/geturl-reqwest", "tectonic_geturl/reqwest"] -native-tls-vendored = [ - "tectonic_bundles/native-tls-vendored", - "tectonic_geturl/native-tls-vendored", -] +native-tls-vendored = ["tectonic_bundles/native-tls-vendored", "tectonic_geturl/native-tls-vendored"] # developer feature to compile with the necessary flags for profiling tectonic. profile = [] @@ -142,23 +136,9 @@ overlay-triplets-path = "dist/vcpkg-triplets" # guidance if they might need to set $VCPKGRS_TRIPLET. [package.metadata.vcpkg.target] x86_64-apple-darwin = { install = ["freetype", "harfbuzz[graphite2]", "icu"] } -aarch64-apple-darwin = { triplet = "arm64-osx", install = [ - "freetype", - "harfbuzz[graphite2]", - "icu", -] } -x86_64-unknown-linux-gnu = { install = [ - "fontconfig", - "freetype", - "harfbuzz[graphite2]", - "icu", -] } -x86_64-pc-windows-msvc = { triplet = "x64-windows-static-release", install = [ - "fontconfig", - "freetype", - "harfbuzz[graphite2]", - "icu", -] } +aarch64-apple-darwin = { triplet = "arm64-osx", install = ["freetype", "harfbuzz[graphite2]", "icu"] } +x86_64-unknown-linux-gnu = { install = ["fontconfig", "freetype", "harfbuzz[graphite2]", "icu"] } +x86_64-pc-windows-msvc = { triplet = "x64-windows-static-release", install = ["fontconfig", "freetype", "harfbuzz[graphite2]", "icu"] } [package.metadata.internal_dep_versions] tectonic_bridge_core = "thiscommit:2023-06-11:PvhF7YB" From c6f5bc386245783c181ca6004c92ce057bae2304 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 15:16:54 +0800 Subject: [PATCH 11/13] fix(clippy): remove unnecessary `to_string()` --- tests/formats.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/formats.rs b/tests/formats.rs index 596ddcfd2..a89ee8520 100644 --- a/tests/formats.rs +++ b/tests/formats.rs @@ -176,12 +176,8 @@ fn test_format_generation(texname: &str, fmtname: &str, sha256: &str) { let observed = info.write_digest.unwrap(); if observed != want_digest { - println!( - "expected {} to have SHA256 = {}", - fmtname, - want_digest.to_string() - ); - println!("instead, got {}", observed.to_string()); + println!("expected {} to have SHA256 = {}", fmtname, want_digest); + println!("instead, got {}", observed); panic!(); } } From 7c664fd6e2b2aaa249275a33e5461735f0d75785 Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 15:17:10 +0800 Subject: [PATCH 12/13] fix(clippy): remove unnecessary borrow --- tests/util/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 91591d7b5..48ad6766f 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -216,7 +216,7 @@ impl<'a> ExpectedFile<'a> { .unwrap_or_else(|| panic!("couldn't Unicode-ify file name of {:?}", pbase)) .replace(std::path::is_separator, "_"); - let mut dec = GzDecoder::new(File::open(&pbase).unwrap()); + let mut dec = GzDecoder::new(File::open(pbase.as_path()).unwrap()); let mut contents = Vec::new(); dec.read_to_end(&mut contents).unwrap(); From 513caa003324ee0426f08d51184e95ca8b5e72be Mon Sep 17 00:00:00 2001 From: winstxnhdw Date: Thu, 27 Jun 2024 16:16:01 +0800 Subject: [PATCH 13/13] fix(clippy): use more efficient cloning --- crates/docmodel/src/document.rs | 4 ++-- crates/engine_spx2html/src/fonts.rs | 8 ++++---- crates/engine_spx2html/src/initialization.rs | 4 ++-- src/driver.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/docmodel/src/document.rs b/crates/docmodel/src/document.rs index 8874b2742..6f6ecbde3 100644 --- a/crates/docmodel/src/document.rs +++ b/crates/docmodel/src/document.rs @@ -263,7 +263,7 @@ impl Document { tried_src_path = true; if let Some(s) = t.to_str() { - name = s.to_owned(); + s.clone_into(&mut name); } } @@ -273,7 +273,7 @@ impl Document { if let Some(Component::Normal(t)) = full_path.components().next_back() { if let Some(s) = t.to_str() { - name = s.to_owned(); + s.clone_into(&mut name); } } } diff --git a/crates/engine_spx2html/src/fonts.rs b/crates/engine_spx2html/src/fonts.rs index a826700bd..e57c383ce 100644 --- a/crates/engine_spx2html/src/fonts.rs +++ b/crates/engine_spx2html/src/fonts.rs @@ -197,13 +197,13 @@ impl FontEnsemble { // Update the info records for the relevant fonts to capture the // established relationship. - self.font_files[regular].family_name = name.clone(); + self.font_files[regular].family_name.clone_from(&name); self.font_files[regular].family_relation = FamilyRelativeFontId::Regular; - self.font_files[bold].family_name = name.clone(); + self.font_files[bold].family_name.clone_from(&name); self.font_files[bold].family_relation = FamilyRelativeFontId::Bold; - self.font_files[italic].family_name = name.clone(); + self.font_files[italic].family_name.clone_from(&name); self.font_files[italic].family_relation = FamilyRelativeFontId::Italic; - self.font_files[bold_italic].family_name = name.clone(); + self.font_files[bold_italic].family_name.clone_from(&name); self.font_files[bold_italic].family_relation = FamilyRelativeFontId::BoldItalic; self.font_families.insert( diff --git a/crates/engine_spx2html/src/initialization.rs b/crates/engine_spx2html/src/initialization.rs index 1ec38ce3f..f56508ffb 100644 --- a/crates/engine_spx2html/src/initialization.rs +++ b/crates/engine_spx2html/src/initialization.rs @@ -167,12 +167,12 @@ impl InitializationState { } fn handle_set_template(&mut self, texpath: &str, _common: &mut Common) -> Result<()> { - self.next_template_path = texpath.to_owned(); + texpath.clone_into(&mut self.next_template_path); Ok(()) } fn handle_set_output_path(&mut self, texpath: &str, _common: &mut Common) -> Result<()> { - self.next_output_path = texpath.to_owned(); + texpath.clone_into(&mut self.next_output_path); Ok(()) } diff --git a/src/driver.rs b/src/driver.rs index 447670632..320ef64fb 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1132,7 +1132,7 @@ impl ProcessingSessionBuilder { } }; - filesystem_root = parent.clone(); + filesystem_root.clone_from(&parent); let pio: Box = Box::new(FilesystemPrimaryInputIo::new(&p)); (pio, Some(p), parent) }