mirror of
https://github.com/typst/typst
synced 2025-05-13 12:36:23 +08:00
Bump MSRV to 1.83 and Rust in CI to 1.85 (#5946)
This commit is contained in:
parent
ebe2543264
commit
69c3f95705
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83.0
|
||||
- uses: dtolnay/rust-toolchain@1.85.0
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo test --workspace --no-run
|
||||
- run: cargo test --workspace --no-fail-fast
|
||||
@ -59,7 +59,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83.0
|
||||
- uses: dtolnay/rust-toolchain@1.85.0
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
@ -73,7 +73,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.80.0
|
||||
- uses: dtolnay/rust-toolchain@1.83.0
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo check --workspace
|
||||
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -44,7 +44,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83.0
|
||||
- uses: dtolnay/rust-toolchain@1.85.0
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
|
@ -5,7 +5,7 @@ resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
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"]
|
||||
edition = "2021"
|
||||
homepage = "https://typst.app"
|
||||
|
@ -350,7 +350,7 @@ fn export_image(
|
||||
.iter()
|
||||
.enumerate()
|
||||
.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)
|
||||
})
|
||||
})
|
||||
|
@ -1455,7 +1455,7 @@ impl<'a> CompletionContext<'a> {
|
||||
let mut defined = BTreeMap::<EcoString, Option<Value>>::new();
|
||||
named_items(self.world, self.leaf.clone(), |item| {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ impl<'a> GridLayouter<'a> {
|
||||
.footer
|
||||
.as_ref()
|
||||
.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)
|
||||
&& !in_last_with_offset(
|
||||
self.regions,
|
||||
@ -1446,7 +1446,7 @@ impl<'a> GridLayouter<'a> {
|
||||
.iter_mut()
|
||||
.filter(|rowspan| (rowspan.y..rowspan.y + rowspan.rowspan).contains(&y))
|
||||
.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
|
||||
@ -1494,7 +1494,7 @@ impl<'a> GridLayouter<'a> {
|
||||
// laid out at the first frame of the row).
|
||||
// Any rowspans ending before this row are laid out even
|
||||
// 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 the rowspan is contained within the footer.
|
||||
y < footer_start || rowspan.y >= footer_start
|
||||
@ -1580,5 +1580,5 @@ pub(super) fn points(
|
||||
/// our case, headers).
|
||||
pub(super) fn in_last_with_offset(regions: Regions<'_>, offset: Abs) -> bool {
|
||||
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)
|
||||
}
|
||||
|
@ -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
|
||||
// last row of cells above us.
|
||||
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();
|
||||
let bottom_y =
|
||||
if use_bottom_border_stroke { grid.rows.len().saturating_sub(1) } else { y };
|
||||
|
@ -588,7 +588,7 @@ impl GridLayouter<'_> {
|
||||
measurement_data: &CellMeasurementData<'_>,
|
||||
) -> bool {
|
||||
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
|
||||
})
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ pub fn line<'a>(
|
||||
let mut items = collect_items(engine, p, range, trim);
|
||||
|
||||
// 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() {
|
||||
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"
|
||||
// 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,
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ fn linebreak_optimized_bounded<'a>(
|
||||
}
|
||||
|
||||
// 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 });
|
||||
}
|
||||
}
|
||||
@ -423,7 +423,7 @@ fn linebreak_optimized_approximate(
|
||||
let total = pred.total + line_cost;
|
||||
|
||||
// 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,
|
||||
|
@ -465,7 +465,7 @@ impl<'a> ShapedText<'a> {
|
||||
None
|
||||
};
|
||||
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))
|
||||
.chain(fallback_func.iter().map(|f| f()))
|
||||
.flatten();
|
||||
@ -570,7 +570,7 @@ impl<'a> ShapedText<'a> {
|
||||
// for the next line.
|
||||
let dec = if ltr { usize::checked_sub } else { usize::checked_add };
|
||||
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;
|
||||
}
|
||||
idx = next;
|
||||
@ -812,7 +812,7 @@ fn shape_segment<'a>(
|
||||
.nth(1)
|
||||
.map(|(i, _)| offset + i)
|
||||
.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
|
||||
|
@ -411,7 +411,7 @@ fn find<'a>(
|
||||
}
|
||||
|
||||
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_score = Some(score);
|
||||
}
|
||||
|
@ -1387,7 +1387,7 @@ impl<'a> CellGrid<'a> {
|
||||
// Include the gutter right before the footer, unless there is
|
||||
// none, or the gutter is already included in the header (no
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ impl FontBook {
|
||||
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_key = Some(key);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ fn is_shapable(engine: &Engine, text: &str, styles: StyleChain) -> bool {
|
||||
{
|
||||
let covers = family.covers();
|
||||
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()
|
||||
});
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ pub(crate) fn write_outline(
|
||||
// (not exceeding whichever is the most restrictive depth limit
|
||||
// of those two).
|
||||
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
|
||||
}) {
|
||||
children = &mut children.last_mut().unwrap().children;
|
||||
@ -83,7 +83,7 @@ pub(crate) fn write_outline(
|
||||
// needed, following the usual rules listed above.
|
||||
last_skipped_level = None;
|
||||
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
|
||||
// have consecutive skipped headings (since none of them are being
|
||||
// added to the bookmark tree), hence the condition above.
|
||||
|
@ -753,7 +753,7 @@ impl<'a> LinkedNode<'a> {
|
||||
// sibling's span number is larger than the target span's number.
|
||||
if children
|
||||
.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) {
|
||||
return Some(found);
|
||||
|
@ -327,8 +327,8 @@ impl PackageVersion {
|
||||
/// missing in the bound are ignored.
|
||||
pub fn matches_eq(&self, bound: &VersionBound) -> bool {
|
||||
self.major == bound.major
|
||||
&& bound.minor.map_or(true, |minor| self.minor == minor)
|
||||
&& bound.patch.map_or(true, |patch| self.patch == patch)
|
||||
&& bound.minor.is_none_or(|minor| self.minor == minor)
|
||||
&& bound.patch.is_none_or(|patch| self.patch == patch)
|
||||
}
|
||||
|
||||
/// Performs a `>` match with the given version bound. The match only
|
||||
|
@ -28,7 +28,7 @@ impl Scalar {
|
||||
///
|
||||
/// If the value is NaN, then it is set to `0.0` in the result.
|
||||
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`].
|
||||
@ -37,17 +37,6 @@ impl Scalar {
|
||||
}
|
||||
}
|
||||
|
||||
// We have to detect NaNs this way since `f64::is_nan` isn’t 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 {
|
||||
fn zero() -> Self {
|
||||
Self(0.0)
|
||||
|
6
flake.lock
generated
6
flake.lock
generated
@ -112,13 +112,13 @@
|
||||
"rust-manifest": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-Yqu2/i9170R7pQhvOCR1f5SyFr7PcFbO6xcMr9KWruQ=",
|
||||
"narHash": "sha256-irgHsBXecwlFSdmP9MfGP06Cbpca2QALJdbN4cymcko=",
|
||||
"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": {
|
||||
"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": {
|
||||
|
@ -10,7 +10,7 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ impl Collector {
|
||||
for entry in walkdir::WalkDir::new(crate::SUITE_PATH).sort_by_file_name() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
if !path.extension().is_some_and(|ext| ext == "typ") {
|
||||
if path.extension().is_none_or(|ext| ext != "typ") {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ impl Collector {
|
||||
for entry in walkdir::WalkDir::new(crate::REF_PATH).sort_by_file_name() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
if !path.extension().is_some_and(|ext| ext == "png") {
|
||||
if path.extension().is_none_or(|ext| ext != "png") {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ impl<'a> Runner<'a> {
|
||||
|
||||
// Compare against reference output if available.
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user