From 47d10efa993d161b9e4cfa836aca0e1ce56d36ab Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 13 Mar 2026 10:47:58 +0100 Subject: [PATCH] Bump edition and expand CI --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++++++----- Cargo.toml | 3 ++- src/lib.rs | 5 +---- src/shared.rs | 18 ++++++++++++------ src/styling.rs | 4 ++-- 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4fa7faf..0321283b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,34 @@ name: Continuous integration on: [push, pull_request] +env: + RUSTFLAGS: "-Dwarnings" + RUSTDOCFLAGS: "-Dwarnings" + +permissions: + contents: read + jobs: - ci: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: dtolnay/rust-toolchain@e814c742d4444ce2f3f6abddea7faf00161ed941 # 1.88.0 + - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 + - run: cargo test --workspace --all-features --no-run + - run: cargo test --workspace --all-features --no-fail-fast + - run: git diff --exit-code + + checks: + name: Check clippy, formatting, and documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - run: cargo build - - run: cargo test --features=_test-unicode-conformance + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: dtolnay/rust-toolchain@e814c742d4444ce2f3f6abddea7faf00161ed941 # 1.88.0 + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 + - run: cargo clippy --workspace --all-targets --all-features + - run: cargo fmt --check --all + - run: cargo doc --workspace --no-deps diff --git a/Cargo.toml b/Cargo.toml index e9dc852d..2a1b0636 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "codex" version = "0.2.0" +rust-version = "1.88" # also change in ci.yml authors = ["The Typst Project Developers"] -edition = "2021" +edition = "2024" description = "Human-friendly notation for Unicode symbols." repository = "https://github.com/typst/codex" readme = "README.md" diff --git a/src/lib.rs b/src/lib.rs index 38d7f511..f7e8cd9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,10 +159,7 @@ mod test { #[test] fn random_sample() { for (key, control) in [ - ( - "backslash", - [("", "\\"), ("not", "⧷"), ("o", "⦸")].as_slice(), - ), + ("backslash", [("", "\\"), ("not", "⧷"), ("o", "⦸")].as_slice()), ("chi", &[("", "χ")]), ("forces", &[("", "⊩"), ("not", "⊮")]), ("interleave", &[("", "⫴"), ("big", "⫼"), ("struck", "⫵")]), diff --git a/src/shared.rs b/src/shared.rs index b9bc09cb..ac09d0de 100644 --- a/src/shared.rs +++ b/src/shared.rs @@ -172,12 +172,18 @@ mod tests { #[test] fn subset() { - assert!(ModifierSet::from_raw_dotted("a") - .is_subset(ModifierSet::from_raw_dotted("a.b"))); - assert!(ModifierSet::from_raw_dotted("a") - .is_subset(ModifierSet::from_raw_dotted("b.a"))); - assert!(ModifierSet::from_raw_dotted("a.b") - .is_subset(ModifierSet::from_raw_dotted("b.c.a"))); + assert!( + ModifierSet::from_raw_dotted("a") + .is_subset(ModifierSet::from_raw_dotted("a.b")) + ); + assert!( + ModifierSet::from_raw_dotted("a") + .is_subset(ModifierSet::from_raw_dotted("b.a")) + ); + assert!( + ModifierSet::from_raw_dotted("a.b") + .is_subset(ModifierSet::from_raw_dotted("b.c.a")) + ); } #[test] diff --git a/src/styling.rs b/src/styling.rs index 87832164..1e777743 100644 --- a/src/styling.rs +++ b/src/styling.rs @@ -228,8 +228,8 @@ impl MathStyle { bold: bool, italic: Option, ) -> MathStyle { - use conversions::*; use MathVariant::*; + use conversions::*; match (variant.unwrap_or(Plain), bold, italic) { (SansSerif, false, Some(false)) if is_latin(c) => MathStyle::SansSerif, (SansSerif, false, _) if is_latin(c) => MathStyle::SansSerifItalic, @@ -368,8 +368,8 @@ impl fmt::Display for ToStyle { /// assert_eq!("𝕩ℽΩ𝔸𞺸𞺧𝟙⅀𞺮", s); /// ``` pub fn to_style(c: char, style: MathStyle) -> ToStyle { - use conversions::*; use MathStyle::*; + use conversions::*; let styled = match style { Plain => [c, '\0'], Bold => [to_bold(c), '\0'],