diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b4f76871..d7c6214ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.77.0 + - uses: dtolnay/rust-toolchain@1.79.0 - uses: Swatinem/rust-cache@v2 - run: cargo test --workspace --no-run - run: cargo test --workspace --no-fail-fast @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.77.0 + - uses: dtolnay/rust-toolchain@1.79.0 with: components: clippy, rustfmt - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8cfc15ed2..51a27ea91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.77.0 + - uses: dtolnay/rust-toolchain@1.79.0 with: target: ${{ matrix.target }} diff --git a/crates/typst-pdf/src/image.rs b/crates/typst-pdf/src/image.rs index 0df67c615..837975013 100644 --- a/crates/typst-pdf/src/image.rs +++ b/crates/typst-pdf/src/image.rs @@ -95,7 +95,7 @@ pub fn write_images(context: &WithGlobalRefs) -> (PdfChunk, HashMap) svg_chunk.renumber_into(&mut chunk.chunk, |old| { *map.entry(old).or_insert_with(|| chunk.alloc.bump()) }); - out.insert(image.clone(), map[&id]); + out.insert(image.clone(), map[id]); } } } diff --git a/crates/typst-svg/src/text.rs b/crates/typst-svg/src/text.rs index dc5442f99..04b75123b 100644 --- a/crates/typst-svg/src/text.rs +++ b/crates/typst-svg/src/text.rs @@ -238,7 +238,7 @@ fn convert_outline_glyph_to_path( /// Convert a bitmap glyph to an encoded image URL. #[comemo::memoize] fn convert_bitmap_glyph_to_image(font: &Font, id: GlyphId) -> Option<(Image, f64, f64)> { - let raster = font.ttf().glyph_raster_image(id, std::u16::MAX)?; + let raster = font.ttf().glyph_raster_image(id, u16::MAX)?; if raster.format != ttf_parser::RasterImageFormat::PNG { return None; } diff --git a/crates/typst/src/foundations/content.rs b/crates/typst/src/foundations/content.rs index c3ab38518..656049dd5 100644 --- a/crates/typst/src/foundations/content.rs +++ b/crates/typst/src/foundations/content.rs @@ -782,7 +782,7 @@ impl Packed { // Safety: // - We have checked the type. // - Packed is repr(transparent). - return Some(unsafe { std::mem::transmute(content) }); + return Some(unsafe { std::mem::transmute::<&Content, &Packed>(content) }); } None } @@ -793,7 +793,9 @@ impl Packed { // Safety: // - We have checked the type. // - Packed is repr(transparent). - return Some(unsafe { std::mem::transmute(content) }); + return Some(unsafe { + std::mem::transmute::<&mut Content, &mut Packed>(content) + }); } None } @@ -804,7 +806,7 @@ impl Packed { // Safety: // - We have checked the type. // - Packed is repr(transparent). - return Ok(unsafe { std::mem::transmute(content) }); + return Ok(unsafe { std::mem::transmute::>(content) }); } Err(content) } diff --git a/crates/typst/src/layout/container.rs b/crates/typst/src/layout/container.rs index 533d6b7e4..58a8d1077 100644 --- a/crates/typst/src/layout/container.rs +++ b/crates/typst/src/layout/container.rs @@ -910,6 +910,7 @@ mod callbacks { // private field and `Content`'s `Clone` impl is // guaranteed to retain the type (if it didn't, // literally everything would break). + #[allow(clippy::missing_transmute_annotations)] f: unsafe { std::mem::transmute(f) }, } } diff --git a/crates/typst/src/text/font/variant.rs b/crates/typst/src/text/font/variant.rs index 644d9f75d..b798426f7 100644 --- a/crates/typst/src/text/font/variant.rs +++ b/crates/typst/src/text/font/variant.rs @@ -110,7 +110,7 @@ impl FontWeight { /// Create a font weight from a number between 100 and 900, clamping it if /// necessary. pub fn from_number(weight: u16) -> Self { - Self(weight.max(100).min(900)) + Self(weight.clamp(100, 900)) } /// The number between 100 and 900. @@ -120,7 +120,7 @@ impl FontWeight { /// Add (or remove) weight, saturating at the boundaries of 100 and 900. pub fn thicken(self, delta: i16) -> Self { - Self((self.0 as i16).saturating_add(delta).max(100).min(900) as u16) + Self((self.0 as i16).saturating_add(delta).clamp(100, 900) as u16) } /// The absolute number distance between this and another font weight. @@ -219,7 +219,7 @@ impl FontStretch { /// Create a font stretch from a ratio between 0.5 and 2.0, clamping it if /// necessary. pub fn from_ratio(ratio: Ratio) -> Self { - Self((ratio.get().max(0.5).min(2.0) * 1000.0) as u16) + Self((ratio.get().clamp(0.5, 2.0) * 1000.0) as u16) } /// Create a font stretch from an OpenType-style number between 1 and 9,