Bump MSRV to 1.83 and Rust in CI to 1.85 (#5946)

This commit is contained in:
Laurenz 2025-02-24 13:28:01 +01:00 committed by GitHub
parent ebe2543264
commit 69c3f95705
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 37 additions and 48 deletions

View File

@ -30,7 +30,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.83.0 - uses: dtolnay/rust-toolchain@1.85.0
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo test --workspace --no-run - run: cargo test --workspace --no-run
- run: cargo test --workspace --no-fail-fast - run: cargo test --workspace --no-fail-fast
@ -59,7 +59,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.83.0 - uses: dtolnay/rust-toolchain@1.85.0
with: with:
components: clippy, rustfmt components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.80.0 - uses: dtolnay/rust-toolchain@1.83.0
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo check --workspace - run: cargo check --workspace

View File

@ -44,7 +44,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.83.0 - uses: dtolnay/rust-toolchain@1.85.0
with: with:
target: ${{ matrix.target }} target: ${{ matrix.target }}

View File

@ -5,7 +5,7 @@ resolver = "2"
[workspace.package] [workspace.package]
version = "0.13.0" version = "0.13.0"
rust-version = "1.80" # also change in ci.yml rust-version = "1.83" # also change in ci.yml
authors = ["The Typst Project Developers"] authors = ["The Typst Project Developers"]
edition = "2021" edition = "2021"
homepage = "https://typst.app" homepage = "https://typst.app"

View File

@ -350,7 +350,7 @@ fn export_image(
.iter() .iter()
.enumerate() .enumerate()
.filter(|(i, _)| { .filter(|(i, _)| {
config.pages.as_ref().map_or(true, |exported_page_ranges| { config.pages.as_ref().is_none_or(|exported_page_ranges| {
exported_page_ranges.includes_page_index(*i) exported_page_ranges.includes_page_index(*i)
}) })
}) })

View File

@ -1455,7 +1455,7 @@ impl<'a> CompletionContext<'a> {
let mut defined = BTreeMap::<EcoString, Option<Value>>::new(); let mut defined = BTreeMap::<EcoString, Option<Value>>::new();
named_items(self.world, self.leaf.clone(), |item| { named_items(self.world, self.leaf.clone(), |item| {
let name = item.name(); let name = item.name();
if !name.is_empty() && item.value().as_ref().map_or(true, filter) { if !name.is_empty() && item.value().as_ref().is_none_or(filter) {
defined.insert(name.clone(), item.value()); defined.insert(name.clone(), item.value());
} }

View File

@ -1377,7 +1377,7 @@ impl<'a> GridLayouter<'a> {
.footer .footer
.as_ref() .as_ref()
.and_then(Repeatable::as_repeated) .and_then(Repeatable::as_repeated)
.map_or(true, |footer| footer.start != header.end) .is_none_or(|footer| footer.start != header.end)
&& self.lrows.last().is_some_and(|row| row.index() < header.end) && self.lrows.last().is_some_and(|row| row.index() < header.end)
&& !in_last_with_offset( && !in_last_with_offset(
self.regions, self.regions,
@ -1446,7 +1446,7 @@ impl<'a> GridLayouter<'a> {
.iter_mut() .iter_mut()
.filter(|rowspan| (rowspan.y..rowspan.y + rowspan.rowspan).contains(&y)) .filter(|rowspan| (rowspan.y..rowspan.y + rowspan.rowspan).contains(&y))
.filter(|rowspan| { .filter(|rowspan| {
rowspan.max_resolved_row.map_or(true, |max_row| y > max_row) rowspan.max_resolved_row.is_none_or(|max_row| y > max_row)
}) })
{ {
// If the first region wasn't defined yet, it will have the // If the first region wasn't defined yet, it will have the
@ -1494,7 +1494,7 @@ impl<'a> GridLayouter<'a> {
// laid out at the first frame of the row). // laid out at the first frame of the row).
// Any rowspans ending before this row are laid out even // Any rowspans ending before this row are laid out even
// on this row's first frame. // on this row's first frame.
if laid_out_footer_start.map_or(true, |footer_start| { if laid_out_footer_start.is_none_or(|footer_start| {
// If this is a footer row, then only lay out this rowspan // If this is a footer row, then only lay out this rowspan
// if the rowspan is contained within the footer. // if the rowspan is contained within the footer.
y < footer_start || rowspan.y >= footer_start y < footer_start || rowspan.y >= footer_start
@ -1580,5 +1580,5 @@ pub(super) fn points(
/// our case, headers). /// our case, headers).
pub(super) fn in_last_with_offset(regions: Regions<'_>, offset: Abs) -> bool { pub(super) fn in_last_with_offset(regions: Regions<'_>, offset: Abs) -> bool {
regions.backlog.is_empty() regions.backlog.is_empty()
&& regions.last.map_or(true, |height| regions.size.y + offset == height) && regions.last.is_none_or(|height| regions.size.y + offset == height)
} }

View File

@ -463,7 +463,7 @@ pub fn hline_stroke_at_column(
// region, we have the last index, and (as a failsafe) we don't have the // region, we have the last index, and (as a failsafe) we don't have the
// last row of cells above us. // last row of cells above us.
let use_bottom_border_stroke = !in_last_region let use_bottom_border_stroke = !in_last_region
&& local_top_y.map_or(true, |top_y| top_y + 1 != grid.rows.len()) && local_top_y.is_none_or(|top_y| top_y + 1 != grid.rows.len())
&& y == grid.rows.len(); && y == grid.rows.len();
let bottom_y = let bottom_y =
if use_bottom_border_stroke { grid.rows.len().saturating_sub(1) } else { y }; if use_bottom_border_stroke { grid.rows.len().saturating_sub(1) } else { y };

View File

@ -588,7 +588,7 @@ impl GridLayouter<'_> {
measurement_data: &CellMeasurementData<'_>, measurement_data: &CellMeasurementData<'_>,
) -> bool { ) -> bool {
if sizes.len() <= 1 if sizes.len() <= 1
&& sizes.first().map_or(true, |&first_frame_size| { && sizes.first().is_none_or(|&first_frame_size| {
first_frame_size <= measurement_data.height_in_this_region first_frame_size <= measurement_data.height_in_this_region
}) })
{ {

View File

@ -154,7 +154,7 @@ pub fn line<'a>(
let mut items = collect_items(engine, p, range, trim); let mut items = collect_items(engine, p, range, trim);
// Add a hyphen at the line start, if a previous dash should be repeated. // Add a hyphen at the line start, if a previous dash should be repeated.
if pred.map_or(false, |pred| should_repeat_hyphen(pred, full)) { if pred.is_some_and(|pred| should_repeat_hyphen(pred, full)) {
if let Some(shaped) = items.first_text_mut() { if let Some(shaped) = items.first_text_mut() {
shaped.prepend_hyphen(engine, p.config.fallback); shaped.prepend_hyphen(engine, p.config.fallback);
} }
@ -406,7 +406,7 @@ fn should_repeat_hyphen(pred_line: &Line, text: &str) -> bool {
// //
// See § 4.1.1.1.2.e on the "Ortografía de la lengua española" // See § 4.1.1.1.2.e on the "Ortografía de la lengua española"
// https://www.rae.es/ortografía/como-signo-de-división-de-palabras-a-final-de-línea // https://www.rae.es/ortografía/como-signo-de-división-de-palabras-a-final-de-línea
Lang::SPANISH => text.chars().next().map_or(false, |c| !c.is_uppercase()), Lang::SPANISH => text.chars().next().is_some_and(|c| !c.is_uppercase()),
_ => false, _ => false,
} }

View File

@ -290,7 +290,7 @@ fn linebreak_optimized_bounded<'a>(
} }
// If this attempt is better than what we had before, take it! // If this attempt is better than what we had before, take it!
if best.as_ref().map_or(true, |best| best.total >= total) { if best.as_ref().is_none_or(|best| best.total >= total) {
best = Some(Entry { pred: pred_index, total, line: attempt, end }); best = Some(Entry { pred: pred_index, total, line: attempt, end });
} }
} }
@ -423,7 +423,7 @@ fn linebreak_optimized_approximate(
let total = pred.total + line_cost; let total = pred.total + line_cost;
// If this attempt is better than what we had before, take it! // If this attempt is better than what we had before, take it!
if best.as_ref().map_or(true, |best| best.total >= total) { if best.as_ref().is_none_or(|best| best.total >= total) {
best = Some(Entry { best = Some(Entry {
pred: pred_index, pred: pred_index,
total, total,

View File

@ -465,7 +465,7 @@ impl<'a> ShapedText<'a> {
None None
}; };
let mut chain = families(self.styles) let mut chain = families(self.styles)
.filter(|family| family.covers().map_or(true, |c| c.is_match("-"))) .filter(|family| family.covers().is_none_or(|c| c.is_match("-")))
.map(|family| book.select(family.as_str(), self.variant)) .map(|family| book.select(family.as_str(), self.variant))
.chain(fallback_func.iter().map(|f| f())) .chain(fallback_func.iter().map(|f| f()))
.flatten(); .flatten();
@ -570,7 +570,7 @@ impl<'a> ShapedText<'a> {
// for the next line. // for the next line.
let dec = if ltr { usize::checked_sub } else { usize::checked_add }; let dec = if ltr { usize::checked_sub } else { usize::checked_add };
while let Some(next) = dec(idx, 1) { while let Some(next) = dec(idx, 1) {
if self.glyphs.get(next).map_or(true, |g| g.range.start != text_index) { if self.glyphs.get(next).is_none_or(|g| g.range.start != text_index) {
break; break;
} }
idx = next; idx = next;
@ -812,7 +812,7 @@ fn shape_segment<'a>(
.nth(1) .nth(1)
.map(|(i, _)| offset + i) .map(|(i, _)| offset + i)
.unwrap_or(text.len()); .unwrap_or(text.len());
covers.map_or(true, |cov| cov.is_match(&text[offset..end])) covers.is_none_or(|cov| cov.is_match(&text[offset..end]))
}; };
// Collect the shaped glyphs, doing fallback and shaping parts again with // Collect the shaped glyphs, doing fallback and shaping parts again with

View File

@ -411,7 +411,7 @@ fn find<'a>(
} }
let score = (matching, Reverse(total)); let score = (matching, Reverse(total));
if best_score.map_or(true, |b| score > b) { if best_score.is_none_or(|b| score > b) {
best = Some(candidate.1); best = Some(candidate.1);
best_score = Some(score); best_score = Some(score);
} }

View File

@ -1387,7 +1387,7 @@ impl<'a> CellGrid<'a> {
// Include the gutter right before the footer, unless there is // Include the gutter right before the footer, unless there is
// none, or the gutter is already included in the header (no // none, or the gutter is already included in the header (no
// rows between the header and the footer). // rows between the header and the footer).
if header_end.map_or(true, |header_end| header_end != footer.start) { if header_end != Some(footer.start) {
footer.start = footer.start.saturating_sub(1); footer.start = footer.start.saturating_sub(1);
} }
} }

View File

@ -160,7 +160,7 @@ impl FontBook {
current.variant.weight.distance(variant.weight), current.variant.weight.distance(variant.weight),
); );
if best_key.map_or(true, |b| key < b) { if best_key.is_none_or(|b| key < b) {
best = Some(id); best = Some(id);
best_key = Some(key); best_key = Some(key);
} }

View File

@ -159,7 +159,7 @@ fn is_shapable(engine: &Engine, text: &str, styles: StyleChain) -> bool {
{ {
let covers = family.covers(); let covers = family.covers();
return text.chars().all(|c| { return text.chars().all(|c| {
covers.map_or(true, |cov| cov.is_match(c.encode_utf8(&mut [0; 4]))) covers.is_none_or(|cov| cov.is_match(c.encode_utf8(&mut [0; 4])))
&& font.ttf().glyph_index(c).is_some() && font.ttf().glyph_index(c).is_some()
}); });
} }

View File

@ -70,7 +70,7 @@ pub(crate) fn write_outline(
// (not exceeding whichever is the most restrictive depth limit // (not exceeding whichever is the most restrictive depth limit
// of those two). // of those two).
while children.last().is_some_and(|last| { while children.last().is_some_and(|last| {
last_skipped_level.map_or(true, |l| last.level < l) last_skipped_level.is_none_or(|l| last.level < l)
&& last.level < leaf.level && last.level < leaf.level
}) { }) {
children = &mut children.last_mut().unwrap().children; children = &mut children.last_mut().unwrap().children;
@ -83,7 +83,7 @@ pub(crate) fn write_outline(
// needed, following the usual rules listed above. // needed, following the usual rules listed above.
last_skipped_level = None; last_skipped_level = None;
children.push(leaf); children.push(leaf);
} else if last_skipped_level.map_or(true, |l| leaf.level < l) { } else if last_skipped_level.is_none_or(|l| leaf.level < l) {
// Only the topmost / lowest-level skipped heading matters when you // Only the topmost / lowest-level skipped heading matters when you
// have consecutive skipped headings (since none of them are being // have consecutive skipped headings (since none of them are being
// added to the bookmark tree), hence the condition above. // added to the bookmark tree), hence the condition above.

View File

@ -753,7 +753,7 @@ impl<'a> LinkedNode<'a> {
// sibling's span number is larger than the target span's number. // sibling's span number is larger than the target span's number.
if children if children
.peek() .peek()
.map_or(true, |next| next.span().number() > span.number()) .is_none_or(|next| next.span().number() > span.number())
{ {
if let Some(found) = child.find(span) { if let Some(found) = child.find(span) {
return Some(found); return Some(found);

View File

@ -327,8 +327,8 @@ impl PackageVersion {
/// missing in the bound are ignored. /// missing in the bound are ignored.
pub fn matches_eq(&self, bound: &VersionBound) -> bool { pub fn matches_eq(&self, bound: &VersionBound) -> bool {
self.major == bound.major self.major == bound.major
&& bound.minor.map_or(true, |minor| self.minor == minor) && bound.minor.is_none_or(|minor| self.minor == minor)
&& bound.patch.map_or(true, |patch| self.patch == patch) && bound.patch.is_none_or(|patch| self.patch == patch)
} }
/// Performs a `>` match with the given version bound. The match only /// Performs a `>` match with the given version bound. The match only

View File

@ -28,7 +28,7 @@ impl Scalar {
/// ///
/// If the value is NaN, then it is set to `0.0` in the result. /// If the value is NaN, then it is set to `0.0` in the result.
pub const fn new(x: f64) -> Self { pub const fn new(x: f64) -> Self {
Self(if is_nan(x) { 0.0 } else { x }) Self(if x.is_nan() { 0.0 } else { x })
} }
/// Gets the value of this [`Scalar`]. /// Gets the value of this [`Scalar`].
@ -37,17 +37,6 @@ impl Scalar {
} }
} }
// We have to detect NaNs this way since `f64::is_nan` isnt const
// on stable yet:
// ([tracking issue](https://github.com/rust-lang/rust/issues/57241))
#[allow(clippy::unusual_byte_groupings)]
const fn is_nan(x: f64) -> bool {
// Safety: all bit patterns are valid for u64, and f64 has no padding bits.
// We cannot use `f64::to_bits` because it is not const.
let x_bits = unsafe { std::mem::transmute::<f64, u64>(x) };
(x_bits << 1 >> (64 - 12 + 1)) == 0b0_111_1111_1111 && (x_bits << 12) != 0
}
impl Numeric for Scalar { impl Numeric for Scalar {
fn zero() -> Self { fn zero() -> Self {
Self(0.0) Self(0.0)

6
flake.lock generated
View File

@ -112,13 +112,13 @@
"rust-manifest": { "rust-manifest": {
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-Yqu2/i9170R7pQhvOCR1f5SyFr7PcFbO6xcMr9KWruQ=", "narHash": "sha256-irgHsBXecwlFSdmP9MfGP06Cbpca2QALJdbN4cymcko=",
"type": "file", "type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.83.0.toml" "url": "https://static.rust-lang.org/dist/channel-rust-1.85.0.toml"
}, },
"original": { "original": {
"type": "file", "type": "file",
"url": "https://static.rust-lang.org/dist/channel-rust-1.83.0.toml" "url": "https://static.rust-lang.org/dist/channel-rust-1.85.0.toml"
} }
}, },
"systems": { "systems": {

View File

@ -10,7 +10,7 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
rust-manifest = { rust-manifest = {
url = "https://static.rust-lang.org/dist/channel-rust-1.83.0.toml"; url = "https://static.rust-lang.org/dist/channel-rust-1.85.0.toml";
flake = false; flake = false;
}; };
}; };

View File

@ -149,7 +149,7 @@ impl Collector {
for entry in walkdir::WalkDir::new(crate::SUITE_PATH).sort_by_file_name() { for entry in walkdir::WalkDir::new(crate::SUITE_PATH).sort_by_file_name() {
let entry = entry.unwrap(); let entry = entry.unwrap();
let path = entry.path(); let path = entry.path();
if !path.extension().is_some_and(|ext| ext == "typ") { if path.extension().is_none_or(|ext| ext != "typ") {
continue; continue;
} }
@ -168,7 +168,7 @@ impl Collector {
for entry in walkdir::WalkDir::new(crate::REF_PATH).sort_by_file_name() { for entry in walkdir::WalkDir::new(crate::REF_PATH).sort_by_file_name() {
let entry = entry.unwrap(); let entry = entry.unwrap();
let path = entry.path(); let path = entry.path();
if !path.extension().is_some_and(|ext| ext == "png") { if path.extension().is_none_or(|ext| ext != "png") {
continue; continue;
} }

View File

@ -161,7 +161,7 @@ impl<'a> Runner<'a> {
// Compare against reference output if available. // Compare against reference output if available.
// Test that is ok doesn't need to be updated. // Test that is ok doesn't need to be updated.
if ref_data.as_ref().map_or(false, |r| D::matches(&live, r)) { if ref_data.as_ref().is_ok_and(|r| D::matches(&live, r)) {
return; return;
} }