From 4bbd4e195bf9e6672c0d53205adebca884a98e77 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 21 Jul 2025 14:19:24 +0200 Subject: [PATCH] Migrate to 2024 edition --- Cargo.toml | 2 +- crates/typst-ide/src/jump.rs | 4 ++-- crates/typst-layout/src/grid/layouter.rs | 2 +- crates/typst-layout/src/math/lr.rs | 4 ++-- crates/typst-layout/src/math/stretch.rs | 2 +- crates/typst-library/src/engine.rs | 2 +- .../typst-library/src/introspection/introspector.rs | 2 +- crates/typst-pdf/src/metadata.rs | 2 +- crates/typst-utils/src/fat.rs | 12 ++++++------ 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0a6678a6a..43a077ddb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ resolver = "2" version = "0.13.1" rust-version = "1.88" # also change in ci.yml authors = ["The Typst Project Developers"] -edition = "2021" +edition = "2024" homepage = "https://typst.app" repository = "https://github.com/typst/typst" license = "Apache-2.0" diff --git a/crates/typst-ide/src/jump.rs b/crates/typst-ide/src/jump.rs index b29bc4a48..c9a53547a 100644 --- a/crates/typst-ide/src/jump.rs +++ b/crates/typst-ide/src/jump.rs @@ -50,7 +50,7 @@ pub fn jump_from_click( } // If there's no link, search for a jump target. - for (mut pos, item) in frame.items().rev() { + for &(mut pos, ref item) in frame.items().rev() { match item { FrameItem::Group(group) => { let pos = click - pos; @@ -177,7 +177,7 @@ pub fn jump_from_cursor( /// Find the position of a span in a frame. fn find_in_frame(frame: &Frame, span: Span) -> Option { - for (mut pos, item) in frame.items() { + for &(mut pos, ref item) in frame.items() { if let FrameItem::Group(group) = item { if let Some(point) = find_in_frame(&group.frame, span) { return Some(pos + point.transform(group.transform)); diff --git a/crates/typst-layout/src/grid/layouter.rs b/crates/typst-layout/src/grid/layouter.rs index d4f11f470..a5803f830 100644 --- a/crates/typst-layout/src/grid/layouter.rs +++ b/crates/typst-layout/src/grid/layouter.rs @@ -1228,7 +1228,7 @@ impl<'a> GridLayouter<'a> { .skip(parent.y) .take(rowspan) .rev() - .find(|(_, &row)| row == Sizing::Auto) + .find(|&(_, &row)| row == Sizing::Auto) .map(|(y, _)| y); if last_spanned_auto_row != Some(y) { diff --git a/crates/typst-layout/src/math/lr.rs b/crates/typst-layout/src/math/lr.rs index 2348025e8..cba794935 100644 --- a/crates/typst-layout/src/math/lr.rs +++ b/crates/typst-layout/src/math/lr.rs @@ -55,7 +55,7 @@ pub fn layout_lr( // Handle MathFragment::Glyph fragments that should be scaled up. for fragment in inner_fragments.iter_mut() { - if let MathFragment::Glyph(ref mut glyph) = fragment { + if let MathFragment::Glyph(glyph) = fragment { if glyph.mid_stretched == Some(false) { glyph.mid_stretched = Some(true); scale(ctx, fragment, relative_to, height); @@ -95,7 +95,7 @@ pub fn layout_mid( let mut fragments = ctx.layout_into_fragments(&elem.body, styles)?; for fragment in &mut fragments { - if let MathFragment::Glyph(ref mut glyph) = fragment { + if let MathFragment::Glyph(glyph) = fragment { glyph.mid_stretched = Some(false); glyph.class = MathClass::Relation; } diff --git a/crates/typst-layout/src/math/stretch.rs b/crates/typst-layout/src/math/stretch.rs index f1a22a814..b9a6b15ae 100644 --- a/crates/typst-layout/src/math/stretch.rs +++ b/crates/typst-layout/src/math/stretch.rs @@ -37,7 +37,7 @@ pub fn stretch_fragment( ) { let size = fragment.size(); - let MathFragment::Glyph(ref mut glyph) = fragment else { return }; + let MathFragment::Glyph(glyph) = fragment else { return }; // Return if we attempt to stretch along an axis which isn't stretchable, // so that the original fragment isn't modified. diff --git a/crates/typst-library/src/engine.rs b/crates/typst-library/src/engine.rs index 43a7b4671..a85fc8ca2 100644 --- a/crates/typst-library/src/engine.rs +++ b/crates/typst-library/src/engine.rs @@ -47,7 +47,7 @@ impl Engine<'_> { } /// Runs tasks on the engine in parallel. - pub fn parallelize(&mut self, iter: P, f: F) -> impl Iterator + pub fn parallelize(&mut self, iter: P, f: F) -> impl Iterator + use where P: IntoIterator, I: Iterator, diff --git a/crates/typst-library/src/introspection/introspector.rs b/crates/typst-library/src/introspection/introspector.rs index 000fbd202..76a0faa35 100644 --- a/crates/typst-library/src/introspection/introspector.rs +++ b/crates/typst-library/src/introspection/introspector.rs @@ -327,7 +327,7 @@ where self.0.entry(key).or_default().push(value); } - fn take(&mut self, key: &K) -> Option> { + fn take(&mut self, key: &K) -> Option + use> { self.0.remove(key).map(|vec| vec.into_iter()) } } diff --git a/crates/typst-pdf/src/metadata.rs b/crates/typst-pdf/src/metadata.rs index 7c546b237..d51cb5335 100644 --- a/crates/typst-pdf/src/metadata.rs +++ b/crates/typst-pdf/src/metadata.rs @@ -9,7 +9,7 @@ use crate::convert::GlobalContext; pub(crate) fn build_metadata(gc: &GlobalContext) -> Metadata { let creator = format!("Typst {}", env!("CARGO_PKG_VERSION")); - let lang = gc.languages.iter().max_by_key(|(_, &count)| count).map(|(&l, _)| l); + let lang = gc.languages.iter().max_by_key(|&(_, &count)| count).map(|(&l, _)| l); let dir = if lang.map(Lang::dir) == Some(Dir::RTL) { TextDirection::RightToLeft diff --git a/crates/typst-utils/src/fat.rs b/crates/typst-utils/src/fat.rs index b31a2bb1e..40751532b 100644 --- a/crates/typst-utils/src/fat.rs +++ b/crates/typst-utils/src/fat.rs @@ -16,11 +16,11 @@ use std::ptr::NonNull; /// to a value whose type implements the trait of `T` and the `vtable` must have /// been extracted with [`vtable`]. #[track_caller] -pub unsafe fn from_raw_parts(data: *const (), vtable: *const ()) -> *const T { +pub unsafe fn from_raw_parts(data: *const (), vtable: *const ()) -> *const T { unsafe { let fat = FatPointer { data, vtable }; debug_assert_eq!(Layout::new::<*const T>(), Layout::new::()); mem::transmute_copy::(&fat) -} +}} /// Create a mutable fat pointer from a data address and a vtable address. /// @@ -29,23 +29,23 @@ pub unsafe fn from_raw_parts(data: *const (), vtable: *const ()) -> * /// to a value whose type implements the trait of `T` and the `vtable` must have /// been extracted with [`vtable`]. #[track_caller] -pub unsafe fn from_raw_parts_mut(data: *mut (), vtable: *const ()) -> *mut T { +pub unsafe fn from_raw_parts_mut(data: *mut (), vtable: *const ()) -> *mut T { unsafe { let fat = FatPointer { data, vtable }; debug_assert_eq!(Layout::new::<*mut T>(), Layout::new::()); mem::transmute_copy::(&fat) -} +}} /// Extract the address to a trait object's vtable. /// /// # Safety /// Must only be called when `T` is a `dyn Trait`. #[track_caller] -pub unsafe fn vtable(ptr: *const T) -> NonNull<()> { +pub unsafe fn vtable(ptr: *const T) -> NonNull<()> { unsafe { debug_assert_eq!(Layout::new::<*const T>(), Layout::new::()); NonNull::new_unchecked( mem::transmute_copy::<*const T, FatPointer>(&ptr).vtable as *mut (), ) -} +}} /// The memory representation of a trait object pointer. ///