summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-06-24 22:11:11 +0200
committerGitHub <noreply@github.com>2024-06-24 20:11:11 +0000
commit45366c0112ac7a6197cee35f1e180c6a00923e05 (patch)
tree8ce9679593c7ace2ce671cd67fec67745955f529 /crates
parente6b531487042aab25fa72c886decf526672a4631 (diff)
Bump Rust in CI (#4445)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-pdf/src/image.rs2
-rw-r--r--crates/typst-svg/src/text.rs2
-rw-r--r--crates/typst/src/foundations/content.rs8
-rw-r--r--crates/typst/src/layout/container.rs1
-rw-r--r--crates/typst/src/text/font/variant.rs6
5 files changed, 11 insertions, 8 deletions
diff --git a/crates/typst-pdf/src/image.rs b/crates/typst-pdf/src/image.rs
index 0df67c61..83797501 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<Image, Ref>)
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 dc5442f9..04b75123 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 c3ab3851..656049dd 100644
--- a/crates/typst/src/foundations/content.rs
+++ b/crates/typst/src/foundations/content.rs
@@ -782,7 +782,7 @@ impl<T: NativeElement> Packed<T> {
// Safety:
// - We have checked the type.
// - Packed<T> is repr(transparent).
- return Some(unsafe { std::mem::transmute(content) });
+ return Some(unsafe { std::mem::transmute::<&Content, &Packed<T>>(content) });
}
None
}
@@ -793,7 +793,9 @@ impl<T: NativeElement> Packed<T> {
// Safety:
// - We have checked the type.
// - Packed<T> is repr(transparent).
- return Some(unsafe { std::mem::transmute(content) });
+ return Some(unsafe {
+ std::mem::transmute::<&mut Content, &mut Packed<T>>(content)
+ });
}
None
}
@@ -804,7 +806,7 @@ impl<T: NativeElement> Packed<T> {
// Safety:
// - We have checked the type.
// - Packed<T> is repr(transparent).
- return Ok(unsafe { std::mem::transmute(content) });
+ return Ok(unsafe { std::mem::transmute::<Content, Packed<T>>(content) });
}
Err(content)
}
diff --git a/crates/typst/src/layout/container.rs b/crates/typst/src/layout/container.rs
index 533d6b7e..58a8d107 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 644d9f75..b798426f 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,